Hello,
Having the matrix d
d
value value2 class
1 1 1 x
2 2 2 x
3 3 3 x
4 4 2 x
5 5 1 y
6 11 3 y
7 12 4 z
8 13 5 z
9 14 6 z
1015 7 z
I want to calculate the
Hi:
Here are three ways, but there are others:
# (1)
# package doBy:
library(doBy)
summaryBy(value + value2 ~ class, data = df)
class value.mean value2.mean
1 x2.5 2.0
2 y8.0 2.0
3 z 13.5 5.5
# (2) aggregate():
with(df,
Thanks,
These functions solve 1 problem ( the mean).
I tried to use them also for the cov matrix but I didn't succed.
Is there any way to calculate the cov matrix for groups?
--
View this message in context:
Try this:
lapply(list(mean, cov), by, data = d[,1:2], INDICES = d[,'class'])
On Mon, Feb 22, 2010 at 6:13 AM, mirauta bmira...@yahoo.com wrote:
Hello,
Having the matrix d
d
value value2 class
1 1 1 x
2 2 2 x
3 3 3 x
4 4 2 x
5
4 matches
Mail list logo