I want to convert a nested list of dataframes to a single dataframe.
The list has some char columns as well as dataframes. Some of the nested dataframes have empty cells. I tried all the solutions on similar topic but none of them are working on this case. My current solution was trying to use tidyr::unnest
and qdapTools::t(mtabulate(data))
.
My current failed working:
page2_1 <- unnest(page2, cols = c(results.extensions, results.releases))
page2_2 <- unnest(page2_1, cols = c(tag))
page2_3 <- page2_2 %>% unnest_wider(., tender.milestones)
Error: Names must be unique.
x These names are duplicated:
* "id" at locations 10 and 30.
* "title" at locations 31 and 62.
* "description" at locations 32 and 63.
With unnest
, we can use names_repair
. The default option checks for duplicated column names with "check_unique"
. According to ?unnest
, the "unique" value would help here
"unique": make sure names are unique and not empty,
library(dplyr)
library(tidyr)
page2_2 %>%
unnest_wider(., tender.milestones, names_repair = 'unique')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.