[R] how to calculate the average values of each row in a matrix
R. Michael Weylandt <michael.weylandt@gmail.com>
michael.weylandt at gmail.com
Sat Jul 20 03:33:16 CEST 2013
On Jul 19, 2013, at 20:19, Elaine Kuo <elaine.kuo.tw at gmail.com> wrote:
> Hello,
>
> I have a matrix (class matrix) composed of GridCell (row and column).
> The matrix value is the beta diversity index value between two grids.
>
> Now I would like to get the average value of each GridCell.
> Please kindly advise how to make the calculation.
> Thank you.
>
Perhaps the rowMeans() function?
MW
> Elaine
>
> The matrix looks like (cited from Michael Friendly)
> I would like to get the average value of each color.
>
>
> Obs stim RPur Red Yel Gy1 Gy2 Green Blue BlP Pur1
> Pur2
>
> 1 RPur . . . . . . .
> . . .
> 2 Red 11.5 . . . . . .
> . . .
> 3 Yel 13.1 6.0 . . . . .
> . . .
> 4 Gy1 12.6 7.9 6.2 . . . .
> . . .
> 5 Gy2 10.6 8.4 8.4 5.2 . . .
> . . .
> 6 Green 10.6 9.4 9.9 6.5 4.1 . .
> . . .
> 7 Blue 10.8 10.2 10.3 8.8 7.0 6.4 .
> . . .
> 8 BlP 7.3 11.3 12.7 11.2 10.4 9.9 4.2
> . . .
> 9 Pur1 5.4 11.5 12.9 11.7 10.8 9.4 8.4
> 4.5 . .
> 10 Pur2 5.0 11.5 10.7 10.2 10.6 10.1 8.1
> 6.4 3 .
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
More information about the R-help
mailing list