[R] how do I calculate means or cov matrix for multivariate groups
Henrique Dallazuanna
wwwhsd at gmail.com
Mon Feb 22 13:19:26 CET 2010
Try this:
lapply(list(mean, cov), by, data = d[,1:2], INDICES = d[,'class'])
On Mon, Feb 22, 2010 at 6:13 AM, mirauta <bmirauta at 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 5 1 y
> 6 11 3 y
> 7 12 4 z
> 8 13 5 z
> 9 14 6 z
> 10 15 7 z
>
> I want to calculate the means and cov matrix for groups x,y,z.
> I know how to do it the long way.
> I tried to use tapply and kmeans but no good results.
> (tapply is a good solution for only 1 variable)
>
>
> Thank you
>
> Bogdan
>
>
> --
> View this message in context: http://n4.nabble.com/how-do-I-calculate-means-or-cov-matrix-for-multivariate-groups-tp1564157p1564157.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list