【发布时间】:2020-11-12 06:06:27
【问题描述】:
对不起,我是 R 新手 我需要准备一个 json 格式的数据框。但是我很难将变量恢复为原始格式 c(1,2,3,...)。例如
library(tidyr)
x<-tibble(x = 1:3, y = list(c(1,5), c(1,5,10), c(1,2,3,20)))
View(x)
这表明
1 1 c(1, 5)
2 2 c(1, 5, 10)
3 3 c(1, 2, 3, 20)
x1<-x %>% unnest(y)
x2<-x1 %>% nest(data=c(y))
View(x2)
This shows
1 1 1 variable
2 2 1 variable
3 3 1 variable
所需的格式是 c(...) 而不是为 json 数据文件做好准备的变量
1 1 c(1, 5)
2 2 c(1, 5, 10)
3 3 c(1, 2, 3, 20)
请帮忙
【问题讨论】:
标签: r json list nested combinations