Hello I would like to reframe all the columns in a tibble that contains all list columns without having to specify all the columns by name. Below contains an example. my_data is all list columns and I want to turn it into a regular dataframe using reframe. I can do this by specifying all the names of the columns.
library(dplyr)
my_data <- tibble(C1 = list(c(1,2,3,4)),
C2 = list(c(5,6,7,8)),
C3 = list(c(9,10,11,12)))
my_data |>
rowwise() |>
reframe(C1, C2, C3) #The output I would like to get
#> # A tibble: 4 × 3
#> C1 C2 C3
#> <dbl> <dbl> <dbl>
#> 1 1 5 9
#> 2 2 6 10
#> 3 3 7 11
#> 4 4 8 12
my_data |>
rowwise() |>
reframe(everything()) #Would like to find a way to reframe all the columns
#> Error in `reframe()`:
#> ℹ In argument: `everything()`.
#> ℹ In row 1.
#> Caused by error:
#> ! `everything()` must be used within a *selecting* function.
#> ℹ See <https://tidyselect.r-lib.org/reference/faq-selection-context.html> for
#> details.
>Solution :
Instead of dplyr::reframe you could use tidyr::unnest_longer like so:
library(tidyr)
my_data |>
tidyr::unnest_longer(everything())
#> # A tibble: 4 × 3
#> C1 C2 C3
#> <dbl> <dbl> <dbl>
#> 1 1 5 9
#> 2 2 6 10
#> 3 3 7 11
#> 4 4 8 12