Created
September 23, 2019 22:38
-
-
Save sharlagelfand/45dca15a87453024b75ac5f0fb630a52 to your computer and use it in GitHub Desktop.
list-col vs tibble-col?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tibble) | |
library(tidyr) | |
x <- tibble(a = 1, | |
b = 1:2, | |
c = 3:4) | |
x | |
#> # A tibble: 2 x 3 | |
#> a b c | |
#> <dbl> <int> <int> | |
#> 1 1 1 3 | |
#> 2 1 2 4 | |
x <- x %>% | |
nest(data = c(b, c)) | |
x | |
#> # A tibble: 1 x 2 | |
#> a data | |
#> <dbl> <list<df[,2]>> | |
#> 1 1 [2 × 2] | |
# cool x has a list-col | |
y <- tibble(a = 1, | |
data = tibble(b = 1:2, | |
c = 3:4)) | |
y | |
#> # A tibble: 2 x 2 | |
#> a data$b $c | |
#> <dbl> <int> <int> | |
#> 1 1 1 3 | |
#> 2 1 2 4 | |
str(y) | |
#> Classes 'tbl_df', 'tbl' and 'data.frame': 2 obs. of 2 variables: | |
#> $ a : num 1 1 | |
#> $ data:Classes 'tbl_df', 'tbl' and 'data.frame': 2 obs. of 2 variables: | |
#> ..$ b: int 1 2 | |
#> ..$ c: int 3 4 | |
# but how do i make y have one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment