Hi All,
Warm greetings, I am stuck at an issue to convert incoming json response to
data frame.
I am using below code to get the data
library(jsonlite)
d1 <- fromJSON('
http://api.openweathermap.org/data/2.5/group?id=524901,
703448,2643743&units=metric&appid=ec0313a918fa729d4372555ada5fb1f8
')
d2 <- as.data.frame(d1)
?
typeof(d2)
list
can you please guide me how can i get this data into pure data.frame
format. The list in d1 has nested data.frame objects.
Note: If you are unable to get data from api then can use below json string
to test it out:
JSON: {"cnt":3,"list":[{"coord":{"lon":37.62,"lat":55.75},"sys":
{"type":1,"id":7323,"message":0.193,"country":"RU","sunrise"
:1484286631,"sunset":1484313983},"weather":[{"id":600,"main":"Snow","
description":"light
snow","icon":"13d"}],"main":{"temp":-3.75,"pressure":1005,"
humidity":86,"temp_min":-4,"temp_max":-3},"visibility":
8000,"wind":{"speed":4,"deg":170},"clouds":{"all":90},"dt":
1484290800,"id":524901,"name":"Moscow"},{"coord":{"lon":30.
52,"lat":50.43},"sys":{"type":1,"id":7358,"message":0.1885,"
country":"UA","sunrise":1484286787,"sunset":1484317236},"weather":[{"id":
804,"main":"Clouds","description":"overcast
clouds","icon":"04d"}],"main":{"temp":-2,"pressure":1009,"
humidity":92,"temp_min":-2,"temp_max":-2},"visibility":
9000,"wind":{"speed":4,"deg":250,"var_beg":210,"var_end":
270},"clouds":{"all":90},"dt":1484290800,"id":703448,"name":
"Kiev"},{"coord":{"lon":-0.13,"lat":51.51},"sys":{"type":1,"
id":5187,"message":0.1973,"country":"GB","sunrise":1484294413,"sunset":
1484324321},"weather":[{"id":802,"main":"Clouds","description":"scattered
clouds","icon":"03n"}],"main":{"temp":0.7,"pressure":1002,"
temp_min":0,"temp_max":2,"humidity":98},"visibility":
10000,"wind":{"speed":6.2,"deg":270},"clouds":{"all":40},
"dt":1484290200,"id":2643743,"name":"London"}]}
Any help is appreciated.
--
Regards
Archit
[[alternative HTML version deleted]]