我读了一个JSON文件,并将其转换为下面输出的数据框
'data.frame': 8 obs. of 46 variables:
$ dayOfWeek : Factor w/ 7 levels "Friday","Monday",..: 5
1 3 4 2 6 7 5
$ expirationTimeUtc : int 1532035962 1532035962 1532035962
1532035962 1532035962 1532035962 1532035962 1532035962
$ moonPhase : Factor w/ 2 levels "First Quarter",..: 1 2 2
2 2 2 2 2
$ moonPhaseCode : Factor w/ 2 levels "FQ","WXG": 1 2 2 2 2 2 2
2
$ moonPhaseDay : int 7 8 9 10 11 12 13 13
$ moonriseTimeLocal : Factor w/ 8 levels "2018-07-19T13:46:10-
0400",..: 1 2 3 4 5 6 7 8
将其解压缩为数据框的最佳方法是什么?
r<-GET("https://api.weather.com/v3/wx/forecast/daily/7day?
geocode=33.74,-84.39&format=json&units=e&language=en-US&apiKey=yourkey")
weather <- content(r, "text")
wData <- fromJSON(weather, simplifyDataFrame = TRUE)
weatherDF <- data.frame(wData)
head(weatherDF)