R - subscript out of bounds & $ operator is invalid for atomic vectors?

I want to get a list daily weather data of different dates from weather underground - meanwindspdi, meanwdird and humidity.

For instance:

date.range <- c("2016-01-29", "2016-01-30", "2016-02-29") 

And the URL for a date - 2016-01-29 :

http://api.wunderground.com/api/API_KEY/history_20160129/q/EGLL.json 

Sample data/ json:

{   ...         "dailysummary": [         { "date": {         "pretty": "12:00 AM GMT on January 29, 2016",         "year": "2016",         "mon": "01",         "mday": "29",         "hour": "00",         "min": "00",         "tzname": "Europe/London"         },         "fog":"0","rain":"1","snow":"0","snowfallm":"", "snowfalli":"","monthtodatesnowfallm":"", "monthtodatesnowfalli":"","since1julsnowfallm":"", "since1julsnowfalli":"","snowdepthm":"", "snowdepthi":"","hail":"0","thunder":"0","tornado":"0","meantempm":"10", "meantempi":"50","meandewptm":"8", "meandewpti":"47","meanpressurem":"1016.97", "meanpressurei":"30.03","meanwindspdm":"32", "meanwindspdi":"20","meanwdire":"SW","meanwdird":"230","meanvism":"12.0", "meanvisi":"7.5","humidity":"82","maxtempm":"12", "maxtempi":"54","mintempm":"7", "mintempi":"45","maxhumidity":"95","minhumidity":"67","maxdewptm":"10", "maxdewpti":"51","mindewptm":"7", "mindewpti":"45","maxpressurem":"1022", "maxpressurei":"30.18","minpressurem":"1011", "minpressurei":"29.86","maxwspdm":"46", "maxwspdi":"29","minwspdm":"26", "minwspdi":"16","maxvism":"30.0", "maxvisi":"19.0","minvism":"4.6", "minvisi":"3.0","gdegreedays":"0","heatingdegreedays":"16","coolingdegreedays":"0","precipm":"0.6", "precipi":"0.02","precipsource":"Precip6GroupSynop","heatingdegreedaysnormal":"","monthtodateheatingdegreedays":"","monthtodateheatingdegreedaysnormal":"","since1sepheatingdegreedays":"","since1sepheatingdegreedaysnormal":"","since1julheatingdegreedays":"","since1julheatingdegreedaysnormal":"","coolingdegreedaysnormal":"","monthtodatecoolingdegreedays":"","monthtodatecoolingdegreedaysnormal":"","since1sepcoolingdegreedays":"","since1sepcoolingdegreedaysnormal":"","since1jancoolingdegreedays":"","since1jancoolingdegreedaysnormal":"" }         ]     } } 

Loop the date.range with the code below:

dailysummary <- fromJSON('http://api.wunderground.com/api/API_KEY/history_20160129/q/EGLL.json')[["history"]][["dailysummary"]]  library(plyr) hdwd <- data.frame() hdwd <- rbind(hdwd, ldply(dailysummary,           function(x) c(x$meanwindspdi, x$meanwdird, x$humidity)         )) 

Error:

Error in x$meanwindspdi : $ operator is invalid for atomic vectors  

So I changed it to:

function(x) c(x$meanwindspdi, x$meanwdird, x$humidity) 

Error:

 Error in x[["meanwindspdi"]] : subscript out of bounds  

What I want to get is similar to this guide (it has the same error too):

Airport Date    Fog Rain    Snow    AvgTemp AvgVisibility   MaxTemp MinTemp SFO 13149   0   1   0   55  14  62  47 SFO 13150   0   1   0   53  11  55  50 SFO 13151   0   1   0   51  14  56  46 SFO 13152   0   0   0   56  16  62  50 SFO 13153   0   0   0   54  14  60  48 SFO 13154   0   1   0   52  14  59  45 SFO 13155   0   1   0   56  14  61  50 SFO 13156   0   0   0   51  16  57  45 SFO 13157   0   0   0   49  16  56  41 SFO 13158   0   0   0   54  10  61  46 

Any ideas?

Replay

Category: json Time: 2016-07-31 Views: 2

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.549 (s). 12 q(s)