I would like to unnest this dataframe.
df <- tibble(
bears = c(1,2,3),
eagles = tibble(
talons = c(2,3,4),
beaks = c("x","y","z")
)
)
So that it looks like
tibble(
bears = c(1,2,3),
talons = c(2,3,4),
beaks = c("x","y","z")
)
I have tried using unnest
and unnest_wider
, flatten
and unlist
but to no avail.
If I run, for example,
test <- df %>%
unnest_wider(eagles, names_sep = "_")
The error is
Error: Assigned data `map(data[[col]], vec_to_wide, col = col, names_sep = names_sep)` must be compatible with existing data.
x Existing data has 3 rows.
x Assigned data has 2 rows.
ℹ Only vectors of size 1 are recycled.
I'm not sure how to resolve this error. Thanks!