List-to-dataframe은 광범위하게 논의되었습니다. here 그러나 나는 매우 간단한 문제에 대한 해결책을 찾을 수 없었습니다 : 항목 수가 다른 목록의 목록. R : 데이터 프레임에 다양한 항목 수의 목록을 변환
이
은hdi[1]
[[1]]
[[1]]$`_2011_hdi_value`
[1] "0.887"
[[1]]$`_1990_hdi_value`
[1] "0.798"
[[1]]$`_2000_2013_average_annual_hdi_growth`
[1] "0.37"
[[1]]$`_1980_hdi_value`
[1] "0.757"
[[1]]$`_2010_hdi_value`
[1] "0.885"
[[1]]$`_2008_hdi_value`
[1] "0.879"
[[1]]$`_1990_2000_average_annual_hdi_growth`
[1] "0.62"
[[1]]$`_2012_hdi_value`
[1] "0.889"
[[1]]$`_2013_hdi_value`
[1] "0.890"
[[1]]$`_2005_hdi_value`
[1] "0.870"
[[1]]$`_2000_hdi_value`
[1] "0.849"
[[1]]$country
[1] "Very high human development"
[[1]]$`_1980_1990_average_annual_hdi_growth`
[1] "0.52"
아직 목록에서 항목 수있는 목록의 첫 번째 목록 목록
require(json)
hdi <- fromJSON(file="http://data.undp.org/resource/y8j2-3vi9.json")
이다 나는를 구축하고자
summary(as.numeric(summary(hdi)[,"Length"]))
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 5.00 16.00 16.00 14.93 16.00 16.00
변화 데이터 시트는 16 열로 이루어지며 NA
은 해당 목록에 누락 된 값을 나타냅니다.
require(RJSONIO)
hdi <- fromJSON("http://data.undp.org/resource/y8j2-3vi9.json")
#get the unique values of the column names
columnnames<-unique(unlist(lapply(hdi,names)))
#subset each element of the list with and rbind them together
res<-do.call(rbind,lapply(hdi,function(x) x[columnnames]))
colnames(res)<-columnnames
여기에서, 당신은 숫자 열을 강요 수에 개체를 강제 :
이러한 NAs가 결과 데이터 프레임에있는 이유는 무엇이며 그 이유는 무엇입니까? –