by Joseph Rickert
The weather is on everybody's mind these days: too much ice and snow east of the Rockies and no rain to speak fo in California. Ram Narasimhan has made it a little easier for R users to keep track of what's going on and also get a historical perspective. His new R package weatherData makes it easy to down load weather data from various stations around the world collecting data. Here is a time series plot of the average temperature recorded at SFO last year with the help of the weatherData's getWeatherForYear() function. It is really nice that the function returns a data frame of hourly data with the Time variable as class POSIXct.
### Some Code to Get Average Temperature at SFO # JB Rickert library(weatherData) library(ggplot2) library(scales) library(plyr) w2013 <- getWeatherForYear("sfo",2013) w2013$shortdate <- strftime(w2013$Time, format="%m-%d") meanTemp <- ddply(w2013, .(shortdate), summarize, mean_T=mean(TemperatureF)) meanTemp$shortdate <- as.Date(meanTemp$shortdate,format="%m-%d") ggplot(meanTemp, aes(shortdate, mean_T)) + geom_line() + scale_x_date(labels=date_format("%m/%d")) + xlab("") + ylab("Mean Temp deg F") + ggtitle("2013 Average Daily Temperature at SFO")
I have just recently (Jan 13, 2014) published an R introduction in "the" German computer magazine, c't. The case study I use is the Basel (Switzerland) temperature data set of the last 150 years.
I show graphical ways of looking at the data but also how to fit models.
It is all in German, but there are lots of pictures, too :-)
I am not in a position to distribute the article since this is the business of the magazine but it is available for Euro 2.50:
http://shop.heise.de/katalog/gipfelsturm-auf-datenberge
Posted by: Andreas | February 07, 2014 at 09:00
Hi, I just run your script and get the error message: Error in seq.int(0, to0 - from, by) : 'to' cannot be NA, NaN or infinite .
How do I tune my R when running your script?
Thank you
Posted by: yishin | February 10, 2014 at 05:12
Hi Yishin:
This is Ram. Joe's script works for me. If you can send me email at ramnarasimhan at gmail dot com, I could maybe try and help.
Thanks,
Ram
Posted by: Ram | February 10, 2014 at 12:14