Ram-N / weatherData

A simple R package that fetches Weather data from WeatherUnderground
64 stars 39 forks source link

why only two years' records were found? #33

Closed crazyhottommy closed 7 years ago

crazyhottommy commented 7 years ago

Hi, First thanks for this package. I installed from github.

weather <- getWeatherForDate("ORD", "2001-01-01", "2017-05-27")
> range(weather$Date)
[1] "2001-01-01 CST" "2002-02-02 CST"

Why I am missing the data after 2002?

Thanks! Tommy

Ram-N commented 7 years ago

Hi Tommy,

Thanks for noticing this. The reason for this is that weatherUnderground doesn't want us to pull a huge volume of data in a single file. (For some reason, they truncate the number of rows to be 400 rows or less.)

Here's working code that should do what you wish:

multi_weather <- lapply(as.character(2001:2004), 
                        function(x){getWeatherForYear("ORD", x)})

df_allyears <- do.call(rbind, multi_weather)

A few others have also asked for it. I might make it a proper function in a future version. For now though, this should work. (Please change the years to whatever you wish them to be.

Please let me know if this doesn't work for you.

crazyhottommy commented 7 years ago

Thanks! this worked!