【发布时间】:2018-07-21 22:49:37
【问题描述】:
我有以下tibble 数据,
h <- structure(list(label = list(list(structure(list(id = 431676528L,
url = "https://api.github.com/repos/emergenzeHack/terremotocentro/labels/per%20sviluppatori",
name = "per sviluppatori", color = "d4c5f9", default = FALSE), .Names = c("id",
"url", "name", "color", "default")), structure(list(id = 442034204L,
url = "https://api.github.com/repos/emergenzeHack/terremotocentro/labels/sito%20principale",
name = "sito principale", color = "5319e7", default = FALSE), .Names = c("id",
"url", "name", "color", "default"))), list(structure(list(id = 442051239L,
url = "https://api.github.com/repos/emergenzeHack/terremotocentro/labels/mappa",
name = "mappa", color = "0052cc", default = FALSE), .Names = c("id",
"url", "name", "color", "default")), structure(list(id = 431676528L,
url = "https://api.github.com/repos/emergenzeHack/terremotocentro/labels/per%20sviluppatori",
name = "per sviluppatori", color = "d4c5f9", default = FALSE), .Names = c("id",
"url", "name", "color", "default")), structure(list(id = 442034204L,
url = "https://api.github.com/repos/emergenzeHack/terremotocentro/labels/sito%20principale",
name = "sito principale", color = "5319e7", default = FALSE), .Names = c("id",
"url", "name", "color", "default"))), list(NA_character_)), mainId = c("216226960",
"215647494", "242390063")), .Names = c("label", "mainId"), row.names = c(NA,
-3L), class = c("tbl_df", "tbl", "data.frame"))
我想将标签中的值与mainId 配对,以便我可以将label 中的每个子元素与其主 ID 链接起来。我正在尝试获取带有标题的tibble:label,url,name,color,mainId。
a similar question 的解决方案可以正常工作,除非NAs 嵌套在label 的子元素中
map_df(h, flatten_dfr)
bind_rows_(x, .id) 中的错误:参数 1 必须有名称
【问题讨论】:
-
您希望删除第三个
mainID,还是将NA用于其他值? -
@alistaire 我想要 NAs
标签: tibble tibble r dplyr flatten tibble