I'm running some scripts in version 3.4.1 using Rstudio.
What I need ? Transform json into table where attributes come columns and objects come rows
That's the script:
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)
The result that I hope is something like
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