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

gail ortoga-r at yahoo.de
Wed Aug 1 17:38:39 CEST 2012


Thank you!!! But I realise I've simplified my data to the point that your
solution doesn't actually work -- not your fault, mine! My list is actually
more complicated than what I presented it to be; it's not composed of
numerical matrices but of lists, each being composed of 7 columns, the first
two of each (the ones that I am interested in, x and y) being numerical.
This is what my list really looks like (truncated):

> summary(mylist)
      Length Class   Mode
moh6  7      density list
moh7  7      density list
moh8  7      density list
...
etc.

> summary(mylist[[3]]) # I've taken number 3 as an example, but they're all
> the same
          Length Class  Mode     
x         512    -none- numeric  
y         512    -none- numeric  
bw          1    -none- numeric  
n           1    -none- numeric  
call        2    -none- call     
data.name   1    -none- character
has.na      1    -none- logical  

Any suggestion how to get the max of column y for each sub-list (moh6, moh7,
moh8 etc.), and to the max of all these individual maxes? By the way,

lapply(list1,FUN=function(x)x[,2][which.max(x[,2])])

gives me the individual maxes (for a list composed of numerical matrices),
but how do I get to the overall max?

Many thanks ...



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



More information about the R-help mailing list