API Data using R

Viewed 28

I am using below code to get weather data from 1st Jan 2016 till March 2016 however, I am getting only one month of data ie march. Not sure what's going wrong here. thanks for the help.

For token I have put imaginary xyx for security and privacy concerns so if someone wants to run the code you'll have to get a new token with ur email.

    base <- 'https://www.ncei.noaa.gov/cdo-web/api/v2/data?'
    datasetid='datasetid=GHCND'
    stationid = '&stationid=GHCND:ASN00087036'
    startd= '&startdate=2016-02-01'
    endd= '&enddate=2016-03-31'
    lmt = '&limit=1000'
    tok = 'xyz'
    url <- paste0(base,datasetid,stationid,startd,endd,lmt)
    
    a <-  GET(url,add_headers("token" = tok))
    
    b <- fromJSON(rawToChar(a$content))
    
    df <- b$results

0 Answers
Related