[R] extracting monthly temperature data

Andy Bunn abunn at montana.edu
Sun Sep 7 20:31:44 CEST 2003


I know that R is very advanced when it comes to DateTime handling. I am
not quite as advanced as R however.

I just downloaded a stupendously ugly dataset of hourly air temperature
from 1985 to 2003. It has a great many NAs. I want to extract mean,
median, max, and min monthly values.

So far I have read it in as object. Date and Time are factors and Temp
is an int.

> summary(temp.dat)
         Date             Time             Temp         
 01/01/1986:    24   03:00  :  6457   Min.   :  -22.00  
 01/01/1987:    24   04:00  :  6457   1st Qu.:   23.00  
 01/01/1988:    24   05:00  :  6457   Median :   34.00  
 01/01/1989:    24   06:00  :  6457   Mean   :   34.35  
 01/01/1990:    24   10:00  :  6457   3rd Qu.:   45.00  
 01/01/1992:    24   11:00  :  6457   Max.   :   89.00  
 (Other)   :154794   (Other):116196   NA's   :52178.00  

I then made a POSIXt object for the dates and times.

> date.time <- strptime(paste(temp.dat$Date, temp.dat$Time), "%m/%d/%Y
%H:")
> class(date.time)
[1] "POSIXt"  "POSIXlt"
> date.time[1]
[1] "1985-10-01 01:00:00"


Now I'm stuck.

Questions: 

What's the best class for reuniting the temperature data with the dates?
A time series? A list?

Depending on the answer, what's the best way to extract, say, the mean
temperatures for Sepetmber?

Thanks in advance, Andy




More information about the R-help mailing list