Re: [R] (IT WAS) Aggregating an its series

2006-04-09 Thread vittorio
Thanks for the brilliant solution.

***AGAIN***

Now - just to go deeper into the **same subject** on which I'm really supposed 
to work very soon - if I want to aggregate by date only data, say, before 
noon (12.00.00) what should I do?

Ciao
Vittorio


Alle 16:13, venerdì 07 aprile 2006, Whit Armstrong ha scritto:
 aggregate(base,by=list(as.factor(format(dates(base),%Y%m%d))),mean,na.
 rm=T)


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Vittorio
 Sent: Friday, April 07, 2006 11:38 AM
 To: r-help@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@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

 __
 R-help@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

__
R-help@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


Re: [R] (IT WAS) Aggregating an its series

2006-04-09 Thread Whit Armstrong
Just strip off the hours component of the dates, then take a subset of the data 
where the hour is = 12.

I did not execute this, so you might need to change it a bit: 

hours - as.integer(format(dates(base),%H))

new.data - base[hours = 12,]

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


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of vittorio
Sent: Sunday, April 09, 2006 6:12 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] (IT WAS) Aggregating an its series

Thanks for the brilliant solution.

***AGAIN***

Now - just to go deeper into the **same subject** on which I'm really supposed 
to work very soon - if I want to aggregate by date only data, say, before noon 
(12.00.00) what should I do?

Ciao
Vittorio


Alle 16:13, venerdì 07 aprile 2006, Whit Armstrong ha scritto:
 aggregate(base,by=list(as.factor(format(dates(base),%Y%m%d))),mean,na.
 rm=T)


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Vittorio
 Sent: Friday, April 07, 2006 11:38 AM
 To: r-help@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@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

 __
 R-help@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

__
R-help@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

__
R-help@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