I'm not sure how to create a reproducible dataset based on this situation. But below is the output from glimpse
, where glimpse identifies 2 columns with item
column is a data.frame
object.
What I want is to have a rectangular tibble, which if item
was just another tibble
, I can simply unnest
.
> glimpse(df)
Columns: 2
$ ID <chr> "A", "B", "C", "D",
$ item <df[,2]> <data.frame[25 x 2]>
> df
# A tibble: 149,826 x 2
ID item$link $value
<chr> <chr> <chr>
1 A~ https://ex.com/api/now/ 941b821e6f9121004d
2 B~ https://ex.com/api/now/ 6c5bdbd46fa9610080
3 C~ https://ex.com/api/now/ 941b821e6f9121004d
The current workaround I use is by converting the data.frame
column as tibble and bind it back to the rest of the table. But this is not ideal if I have many columns with this data.frame
type. Notice how the important column identifier which is item
is now lost as it only captures link
and value
.
If there're multiple columns with data.frame
type, this will generate an error since these columns will all be called link
and value
.
df <- bind_cols(df %>% dplyr::select(ID), as_tibble(dataset$item))
> df
# A tibble: 149,826 x 3
number link value
<chr> <chr> <chr>
1 A~ https://ex.com/api/now/ 941b821e6f9121004d
2 B~ https://ex.com/api/now/ 6c5bdbd46fa9610080
3 C~ https://ex.com/api/now/ 941b821e6f9121004d