请参阅下面的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_history [1,17]
即:Szcezesny 47
答案 0 :(得分:1)
不确定我理解这个难度。不会只是:
as.data.frame(a$season.history)