请参阅下面的R代码,我正在使用JSONlite包从一个网站抓取数据:
>url <- "http://fantasy.premierleague.com/web/api/elements/"
>a<-fromJSON(paste0(url, 1))
>a给出了以下输出:
$id
[1] 1
$photo
[1] "59936.jpg"
$web_name
[1] "Szczesny"
$event_explain
list()
$fixture_history
$fixture_history$all
list()
$fixture_history$summary
list()
$season_history
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17]
[1,] "2008/09" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "45" "0"
[2,] "2009/10" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "45" "0"
[3,] "2010/11" "1350" "0" "0" "6" "19" "0" "1" "0" "1" "0" "45" "0" "0" "0" "43" "62"
[4,] "2011/12" "3420" "0" "0" "13" "49" "0" "1" "0" "2" "0" "82" "8" "469" "0" "59" "139"
[5,] "2012/13" "2250" "0" "0" "10" "24" "0" "1" "0" "1" "0" "71" "3" "314" "0" "53" "102"
[6,] "2013/14" "3330" "0" "0" "16" "41" "0" "1" "0" "2" "0" "113" "4" "475" "194" "59" "157"
[7,] "2014/15" "1498" "0" "0" "3" "21" "0" "0" "0" "1" "0" "44" "0" "172" "215" "52" "47" 现在我想把season_history数据作为一个数据框架或矩阵进行分析,如何去做呢?我想要一个带有标题的最终输出:
1.web_name
2.$season_history1,17
那就是: Szcezesny 47
发布于 2015-08-01 06:56:03
我不确定我是否理解困难。会不会是:
as.data.frame(a$season.history)https://stackoverflow.com/questions/31758905
复制相似问题