Re: [R] aggregate function

2007-04-23 Thread Gabor Grothendieck
try this. The first group of lines recreates your data frame, DF, and the last line is the aggregate: Input - DateTimez 2006-01-01 21:00 6,2 2006-01-01 22:00 5,7 2006-01-01 23:00 3,2 2006-01-02 00:00 7,8 2006-01-02 01:00 6,8 2006-01-02

Re: [R] aggregate function

2007-04-23 Thread Michel Schnitz
it works. thanks a lot. Gabor Grothendieck wrote: try this. The first group of lines recreates your data frame, DF, and the last line is the aggregate: Input - DateTimez 2006-01-01 21:00 6,2 2006-01-01 22:00 5,7 2006-01-01 23:00 3,2 2006-01-02

Re: [R] aggregate function

2007-04-23 Thread Martin Becker
If monthly should aggregate per -mm combination, you could try something like aggregate(x$z,list(cut(as.Date(x$Date),m)),mean) for monthly aggregation and aggregate(x$z,list(cut(as.Date(x$Date),y)),mean) for yearly means. If monthly aggregation should aggregate over different years

Re: [R] aggregate function with 'NA'

2006-10-01 Thread Peter Dalgaard
Frank [EMAIL PROTECTED] writes: aggregate(frame[,c(-1)],list(frame$Day,frame$Time),mean) My problem is now that I do not obtain a 'mean' for Day=M/Time=0 and Day=M/Time=1, because aggregate ignores all values for a grouping variable if NA occurs. No. But mean() will give an NA

Re: [R] aggregate function with 'NA'

2006-10-01 Thread Johan Sandblom
aggregate(frame[,c(-1)],list(frame$Day,frame$Time),mean, na.rm=T) 2006/10/1, Frank [EMAIL PROTECTED]: Dear r-help reader, I have some problems with the aggregate function. My datframe looks like frame Day Time V1 V2 1 M0 3 NA 2 M0 4 NA 3 M0 5 2 4 M1 NA

Re: [R] aggregate function with 'NA'

2006-10-01 Thread Gabor Grothendieck
See ?mean and note the na.rm= argument: aggregate(frame[-1], frame[1:2], mean, na.rm = TRUE) On 10/1/06, Frank [EMAIL PROTECTED] wrote: Dear r-help reader, I have some problems with the aggregate function. My datframe looks like frame Day Time V1 V2 1 M0 3 NA 2 M0 4

Re: [R] aggregate function....

2006-03-31 Thread Stephane CRUVEILLER
Nice trick, thx... Stéphane. On Wed, 2006-03-29 at 11:17 -0500, jim holtman wrote: try 'by': x S_id AF_Class count... R_gc_percent S_length 5 82644971 30 0.4835678 6 826449737 0.4835678 8 82645541 31

Re: [R] aggregate function....

2006-03-29 Thread jim holtman
try 'by': x S_id AF_Class count... R_gc_percent S_length 5 82644971 30 0.4835678 6 826449737 0.4835678 8 82645541 31 0.5138894 9 82645542 11 0.5138894 10 826455431

Re: [R] aggregate function

2004-07-26 Thread TEMPL Matthias
Hi, # x ... your frame attach(x) sum(Total[Year==1997 Tus 0]) I hope this helps Best, Matthias -Ursprüngliche Nachricht- Von: Luis Rideau Cruz [mailto:[EMAIL PROTECTED] Gesendet: Montag, 26. Juli 2004 14:52 An: [EMAIL PROTECTED] Betreff: [R] aggregate function Hi all, I

Re: [R] aggregate function

2004-07-26 Thread TEMPL Matthias
Hi, # x ... your frame attach(x) sum(Total[Year==1997 Tus 0]) I hope this helps Best, Matthias Templ -Ursprüngliche Nachricht- Von: Luis Rideau Cruz [mailto:[EMAIL PROTECTED] Gesendet: Montag, 26. Juli 2004 14:52 An: [EMAIL PROTECTED] Betreff: [R] aggregate function

RE: [R] aggregate function

2004-07-26 Thread Liaw, Andy
I would try something like: lapply(frame[3:5], function(i) tapply(frame$Total[i0], frame$Year[i0], sum)) $Tus 1994 1995 1997 1999 1121 $Whi 1995 1997 1999 1.00 4.00 2.04 $Norw 1994 1995 1997 1998 1999 11512 HTH, Andy From: Luis Rideau Cruz Hi

RE: [R] aggregate function

2004-07-26 Thread Gabor Grothendieck
[Sorry if this gets posted twice. I have been having some problems with gmane posting.] We can use rowsum like this: rowsum(frame$Total * (frame[,3:5]0), frame$Year) Tus Whi Norw 1994 1 0.00 1 1995 1 1.00 1 1997 2 4.00 5 1998 0 0.00 1