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
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
--- [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
cc
Subject
01/10/2007 17:57 [R] mean of subse
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
5 matches
Mail list logo