new in R, so please forgive for the lack of knowledge. I need to take the weather data for a specific time interval in R using wunderground. There is a command for that, but it is not hourly. I need to obtain the hourly data from 2015 to 2017. So, I need to write a for loop. The code which is used for a single date for the specific weather conditions is:
weather <- getWeatherForDate("IMUU011F4", "2015-01-01",
station_type = "id", opt_detailed = TRUE, opt_custom_columns = TRUE,
custom_columns = c(3, 7, 9))
So, I need to use this code for all days in 2 year, have a single file for 2 years.
I can't able to write the for loop.
Can anyone help me.
Thank you.
No loop is required to pull a single weather station for 2 years. Instead, use the
end_date=argument. Since you're starting on January 1, 2015, the end date would be December 31, 2016.The download process writes a lot of data to the R console, starting with the following:
The resulting data frame looks like this.
If you want to obtain the weather for multiple weather stations, this can be accomplished with an
apply()function. Note that this will take a number of minutes to execute, since the IMUU011F4 weather station generated over 203,000 rows of output for the 2 year data request.