0
library(weatherData)
for(i in 2003:2016) {

   c <- (getWeatherForYear(station_id = "BOS", year = i))

}

I am writing a loop to get the weather data from year 2003 to year 2016 from the function: getWeatherForYear and combine it into a dataframe

But after looping, dataframe only shows the weather data in year 2016 "not from year 2003 to 2016"

Could someone help me for fixing the loop that will produce a dataframe include the yearly weather data from year 2003 to 2016?

Thanks a lot

Huang
  • 33
  • 3

1 Answers1

0
df <- do.call(
    rbind,
    lapply(
        2003:2016, 
        function(i) getWeatherForYear(station_id = "BOS", year = i)
    )
)
Iaroslav Domin
  • 2,525
  • 9
  • 17