[R] extracting monthly temperature data
spencer.graves at pdf.com
Sun Sep 7 21:01:42 CEST 2003
What is "class(temp.dat)"? Have you considered "?data.frame"? If
"temp.dat" is a data.frame, you can recombine date.time with Temp via
temp.dat$date.time <- date.time.
Then you can "rm(date.time)", because the above command makes a copy
as a column of the data.frame temp.dat.
I have not been working with POSIXt, so I can't answer your question
about how to get monthly means, other than to ask if you know about
subscripting with a logical vector, "aggregate" and "tapply"?
hope this helps. spencer graves
Andy Bunn wrote:
> 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.
> 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
>  "POSIXt" "POSIXlt"
>  "1985-10-01 01:00:00"
> Now I'm stuck.
> 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
> R-help at stat.math.ethz.ch mailing list
More information about the R-help