[R] Aggregating an its series

Whit Armstrong whit at twinfieldscapital.com
Fri Apr 7 18:13:45 CEST 2006


aggregate(base,by=list(as.factor(format(dates(base),"%Y%m%d"))),mean,na.
rm=T)


-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Vittorio
Sent: Friday, April 07, 2006 11:38 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Aggregating an its series

I'm using a very long irregular time-series of air temperature and
relative humidity of this kind (this is an extract only)

its.format("%
Y%d%m %X)
> base
                                 T  H
20020601
12.00.00 27.1 47
20020601 15.00.00 29.1 39
20020601 18.00.00 27.4 39
20020601 21.00.00 24.0 40
20020602 0.00.00  22.0 73
20020602 3.00.00
19.2 49
20020602 6.00.00  19.5 74
20020602 9.00.00  24.8 45
20020602
12.00.00 27.7 NA
20020602 15.00.00 29.2 39
20020602 18.00.00 27.2 44
20020602 21.00.00 23.9 50
20020603 0.00.00  21.0 75
20020603 3.00.00
19.6 65
20020603 6.00.00  19.8 71
20020603 9.00.00  23.2 67
20020603
12.00.00 24.9 65
20020603 15.00.00 21.7 74
20020603 18.00.00 22.8 63
20020603 21.00.00 21.2 75
20020604 0.00.00  18.0 91

I would like to
aggregate T and H by day and produce another its of this kind

> aggr
               T   H
20020601 NA NA
20020602 NA NA
20020603 NA NA
20020604 NA NA

where the daily average of T and H (not counting the NA
values) is is put in aggr.

What is the quickest way to get this
result?

Thanks

Vittorio

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list