We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
library(dtplyr) library(dplyr, warn.conflicts = FALSE)
data <- data.frame(x = c("A", "A", "B", "B"), y = c(1,2,3,4))
df <- lazy_dt(data) %>% group_by(x) %>% transmute(lead(y,1)) %>% ungroup() %>% collect()
class(df$lead(y, 1))
lead(y, 1)
The text was updated successfully, but these errors were encountered:
If you group by and use the lead/lag functions the resulting column becomes a list instead of the input datatype
library(dtplyr) library(dplyr, warn.conflicts = FALSE) data <- data.frame(x = c("A", "A", "B", "B"), y = c(1,2,3,4)) df <- lazy_dt(data) %>% group_by(x) %>% transmute(lead(y,1)) %>% ungroup() %>% collect() df2 <- data %>% group_by(x) %>% transmute(lead(y,1)) %>% ungroup() class(df$`lead(y, 1)`) #> [1] "list" class(df2$`lead(y, 1)`) #> [1] "numeric"
Created on 2024-02-22 with reprex v2.1.0
Sorry, something went wrong.
This is actually a data.table issue that has been fixed in their latest development version Rdatatable/data.table#5939
data.table
If you update your data.table to the dev version using data.table::update_dev_pkg() it will work correctly
data.table::update_dev_pkg()
No branches or pull requests
library(dtplyr)
library(dplyr, warn.conflicts = FALSE)
data <- data.frame(x = c("A", "A", "B", "B"), y = c(1,2,3,4))
df <- lazy_dt(data) %>%
group_by(x) %>%
transmute(lead(y,1)) %>%
ungroup() %>%
collect()
class(df$
lead(y, 1)
)The text was updated successfully, but these errors were encountered: