我正在使用Rstudio在3.4.1版中运行一些脚本。
我需要什么? 将json转换为表,其中属性为列,对象为行
脚本:
library(data.table)
library(jsonlite)
url <- 'http://ergast.com/api/f1/2004/1/results.json'
res <- fromJSON(file=url)
drivers <- res$MRData$RaceTable$Races$Results[[1]]$Driver
colnames(drivers)
我希望的结果是
givenName familyName code nationality
1 Michael Schumacher MSC German
2 Rubens Barrichello BAR Brazilian
3 Fernando Alonso ALO Spanish
4 Ralf Schumacher SCH German
5 Juan Pablo Montoya MON Colombian
6 Jenson Button BUT British
7 Jarno Trulli TRU Italian
8 David Coulthard COU British
9 Takuma Sato SAT Japanese
10 Giancarlo Fisichella FIS Italian