[R] apply function over same column of all objects in a list

gail ortoga-r at yahoo.de
Wed Aug 1 15:43:38 CEST 2012


Hello. Please forgive me if this problem has already been posted (and solved)
by someone else ... I can't find it anywhere though it seems so very basic.
Here it is:

I have a list comprised of several matrices, each of which has two columns.

> list
[[1]]
        [,1] [,2]
[1,]    1     3
[2,]    2     4

[[2]]
        [,1] [,2]
[1,]    5     7
[2,]    6     8

[[3]]
        [,1]   [,2]
[1,]    9      11
[2,]    10    12

I would like R to give me the highest value (max) of each matrice's 2nd
column, and also the max of all those individual highest values. I have
tried 

matrix.max <- for (i in 1:3) {
mapply ( max, list [[i]] [2] )
}

for each column's max and 

total.max <- for (i in 1:3) {
max(mapply ( max, list [[i]] [2] ))
}

for the total max, but neither works (result: NULL). What am I doing wrong?

 Thanks a lot,
Gail



--
View this message in context: http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list