-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
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
Propose fill args in dt_unnest() #25
Comments
I like this idea! Definitely is a natural extension. If you want, feel free to do a pull request with this and I'll merge it and add you to the contributor list. |
@TysonStanley The new version of pacman::p_load(tidyfast, data.table, magrittr)
df1 <- data.table(a = "a", b = 1)
df2 <- data.table(a = rep("a", 3), b = 1:3, c = 1:3)
nested_df <- data.table(id = 1:2,
list_col = list(df1, df2))
nested_df %>%
dt_unnest(list_col)
#> Error in `[.data.table`(dt_, , eval(col)[[1L]], by = others): j doesn't evaluate to the same number of columns for each group |
That is interesting... That was one advantage to using |
Maybe extract the list column and check if the nested data.tables have a consistent number of columns? df1 <- data.table(a = "a", b = 1)
df2 <- data.table(a = rep("a", 3), b = 1:3, c = 1:3)
test_list <- list(df1, df2)
if (length(unique(lengths(test_list))) > 1) {
"rbindlist code"
} else {
"[[1]] code"
}
#> [1] "rbindlist code" |
Yeah, I was thinking something similar. I can't find anything with the |
@TysonStanley @markfairbanks : thanks for bringing this up again. I do encounter this quite often as a result of |
Reprex and proposal below.
Created on 2020-04-05 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: