[R] how do I calculate means or cov matrix for multivariate groups

2010-02-22 Thread mirauta
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

Re: [R] how do I calculate means or cov matrix for multivariate groups

2010-02-22 Thread Dennis Murphy
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,

Re: [R] how do I calculate means or cov matrix for multivariate groups

2010-02-22 Thread mirauta
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:

Re: [R] how do I calculate means or cov matrix for multivariate groups

2010-02-22 Thread Henrique Dallazuanna
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