[R] extracting monthly temperature data

Andy Bunn abunn at montana.edu
Sun Sep 7 21:30:11 CEST 2003


I can make a data.frame out of the data with the POSIXt objects in it
with the temp data. It's the syntax of the aggregate command that is
eluding me if aggregate and a data frame is the right way to go.


# remake a data frame
temp.dat <- data.frame(date.time, temp.dat$Temp)
colnames(temp.dat) <- c("date", "temp")

> summary(temp.dat)
      date                          temp         
 Min.   :1985-10-01 01:00:00   Min.   :  -22.00  
 1st Qu.:1990-05-02 03:15:00   1st Qu.:   23.00  
 Median :1994-11-01 06:30:00   Median :   34.00  
 Mean   :1994-10-19 13:07:38   Mean   :   34.35  
 3rd Qu.:1999-04-05 17:45:00   3rd Qu.:   45.00  
 Max.   :2003-09-05 16:00:00   Max.   :   89.00  
                               NA's   :52178.00  

aggregate(temp.dat$temp, list(temp.dat$date$mon == 9), mean)


Thx, A




More information about the R-help mailing list