Skip to content
Prev 302028 / 398502 Next

apply function over same column of all objects in a list

On Wed, Aug 1, 2012 at 8:43 AM, gail <ortoga-r at yahoo.de> wrote:
I think what you just want is to put the "get second column" part
within the function that you apply() [Actually lapply() since you have
a list] -- to put it another way, note that "get the second column"
can be considered part of the operation you perform on each list
element, rather than defining the thing to which you apply the max()
function.

Something like this results:

lapply(list, function(x) max(x[,2]))

This will go over the list and apply the function "get the max of the
second column"

Best,
Michael