-
Notifications
You must be signed in to change notification settings - Fork 272
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
Better document downside of named elements in list_cbind()
#1080
Comments
What are you trying to do? It's most likely that you should avoid the packing step in the first place. |
Thanks for responding (and everything else you do)! I am not sure how to avoid the packing as
I have not found a source that explains packed data frames or how to pass arguments to vec_cbind to unpack them as part of the functional call to list_cbind. Perhaps a vignette could be added to tidyr. We can just pipe to flatten I guess but that seems to be an extra step that the newer functions such as pivot_wider etc try to avoid by using arguments. Appreciate any recommendations. |
Oooh sorry, I think I missed the underlying issue here. You're getting this behaviour because library(purrr)
x2 <- list(
a = data.frame(x = 1:2),
b = data.frame(y = "a")
)
str(list_cbind(unname(x2)))
#> 'data.frame': 2 obs. of 2 variables:
#> $ x: int 1 2
#> $ y: chr "a" "a" Created on 2023-07-27 with reprex v2.0.2 I'll think about how to point this out in the docs. |
list_cbind()
Thanks for the explanation and the solution approach! p.s. FYI even Chat GPT can't explain packed data.frames.:) What is a good reference to explain the "packed data.frame" in R? |
list_cbind calls vec_cbind which produces "packed data frame columns" with named inputs.
I am not familiar with packed data frame columns so was expecting to get a data frame with columns that were atomic vectors. The example from the list_cbind help (below) shows a different structure. This different structure also means the result of list_cbind displays differently in an R script than in a qmd/rmd code chunk .
Suggest adding additional information or suggestions in the help (or a vignette) on using unpack() how to convert the result of list_cbind into an unpacked data frame.
An alternative might be to add unpack to the list_cbind() as an argument to allow users to unpack as part of the function.
The text was updated successfully, but these errors were encountered: