On Nov 23, 2012, at 10:04 AM, Dominic Roye wrote:
Hello,
I want to filter the daily maximum temperature. For this i made this
skript, but it come out wrong results. Can anybody help me?
Thanks for your help!
Best regards
datos$X <- as.POSIXct(strptime(datos$X, "%d/%m/%Y %H:%M:%S"))
z <- aggregate(zoo(datos$Ta), as.POSIXct(datos$X), max)
You do not say what you mean by "filter the daily maximum temperature"
but perhaps you just want the maimums on a given date? Perhaps:
z <- aggregate(zoo(datos$Ta), as.Date(as.character(datos$X)), max,
na.rm=TRUE)
# You won't be calculating by "date" unless you do some sort of
conversion. I see below that you have X as a factor so it might be
needed to calculate using as.character for a factor.)
(Not sure that the zoo(.) is needed, and I'm a bit worried that it is
there. You seem to have convinced as.POSIXct to use 2010-01-01 as the
strating data which seems weird)
--
David.
str(datos)
'data.frame': 17137 obs. of 5 variables:
$ X : Factor w/ 17136 levels "00/01/1900 0:00:00",..: 2 3 4 5 6 7 8
9 10 11 ...
$ Ta: num 5.28 5.45 5.54 5.54 5.51 5.51 5.5 5.56 5.58 5.63 ...
$ HR: int 100 100 100 100 100 100 100 100 100 100 ...
$ RS: int 0 0 0 0 0 0 0 0 0 0 ...
$ v : num 2.3 2.5 1.1 2.3 2.2 2.1 2.2 2.9 2.4 2.6 ...
str(z)
‘zoo’ series from 2010-01-01 00:10:00 to 2010-04-29 23:50:00
Data: num [1:17129] 5.28 5.45 5.54 5.54 5.51 5.51 5.5 5.56 5.58
5.63 ...
Index: POSIXct[1:17129], format: "2010-01-01 00:10:00" "2010-01-01
00:20:00" "2010-01-01 00:30:00" "2010-01-01 00:40:00" ...
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
Alameda, CA, USA
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.