我想解除这个数据框的嵌套。
df <- tibble(
bears = c(1,2,3),
eagles = tibble(
talons = c(2,3,4),
beaks = c("x","y","z")
)
)
所以它看起来像
tibble(
bears = c(1,2,3),
talons = c(2,3,4),
beaks = c("x","y","z")
)
我尝试过使用unnest
and unnest_wider
, flatten
and unlist
但无济于事。
例如,如果我跑步,
test <- df %>%
unnest_wider(eagles, names_sep = "_")
错误是
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.
我不知道如何解决这个错误。谢谢!