Re: [R] mean of subset of rows

2007-10-02 Thread darteta001
Thankyou all for your answers, I have decided using aggregate() but I will keep in mind tapply(). I was wondering if it is possible to tell aggregate to use two functions at the same time, i.e., mean() and sd (), or is it better to call aggregate() two times, one for mean, and another for sd and

Re: [R] mean of subset of rows

2007-10-01 Thread Jeffrey Robert Spies
You were on the right track with the for loop, but often you can do the same thing looplessly (I know, it's not really a word) in R: If your data is like this: data<-data.frame(ID=rep(letters[1:4], 5), size=runif(20)) then apply either tapply(data$size, data$ID, mean) or aggregate(data$size

Re: [R] mean of subset of rows

2007-10-01 Thread John Kane
--- [EMAIL PROTECTED] wrote: > Dear list, > this must be an easy one: > > I have a data.frame of two columns, "ID" with four > different levels (A > to D) and numerical "size", and each of the 4 > different IDs is > repeated a > different number of times. I would like to get the > mean size

Re: [R] mean of subset of rows

2007-10-01 Thread joris . dewolf
cc Subject 01/10/2007 17:57 [R] mean of subse

[R] mean of subset of rows

2007-10-01 Thread darteta001
Dear list, this must be an easy one: I have a data.frame of two columns, "ID" with four different levels (A to D) and numerical "size", and each of the 4 different IDs is repeated a different number of times. I would like to get the mean size for each ID as another data.frame. I have tried th