Dear Larry,
dat - data.frame(CAT=sample(c(a,b,c,d),100,rep=T), x=rnorm(100))
tapply(dat[,2],dat[,1, drop = FALSE], mean)
tapply(dat[,2],dat[,1, drop = FALSE], sum)
I hope this helps,
Samuel.
Larry White [EMAIL PROTECTED] wrote:
At the risk of being wacked for asking what should be
At the risk of being wacked for asking what should be obvious
I have a data frame with one categorical variable CAT and several
numeric variables. I want to be able to get simple statistics on the
numeric variables by level. For example, just as you can use table
(CAT) to get the counts,
White [EMAIL PROTECTED]
To: R-help@stat.math.ethz.ch
Sent: Thursday, March 24, 2005 5:12 PM
Subject: [R] summing values by group
At the risk of being wacked for asking what should be obvious
I have a data frame with one categorical variable CAT and several
numeric variables. I want to be able
Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Larry White
Sent: Thursday, March 24, 2005 10:12 AM
To: R-help@stat.math.ethz.ch
Subject: [R] summing values by group
At the risk of being wacked for asking what should be obvious
I have a data frame with one categorical