Elaine Kuo
2013-Jul-20 01:19 UTC
[R] how to calculate the average values of each row in a matrix
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. 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. Michael Weylandt <michael.weylandt@gmail.com>
2013-Jul-20 01:33 UTC
[R] how to calculate the average values of each row in a matrix
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.
Possibly Parallel Threads
- how to convert a data.frame to a list of dist objects for individual differences MDS?
- Memory problem with GridCell*Editor
- Troubles on retrieving rownames
- failure to connect to Bloomber using Rbbg from batch script on Windows
- expand gridded matrix to higher resolution