enedene
enedene

Reputation: 3635

Using lapply on multiple functions

HierCluster is the list of data frames.

I can get the info about one cluster like this:

tail(sort(colMeans(HierCluster[[i]])))

where i is an i-th element in the list.

I used lapply to get the info on all the clusters at once:

lapply(lapply(lapply(HierCluster, colMeans), sort), tail)

But using lapply 3 times seems rather cumbersome, is there a more practical way of doing this?

Upvotes: 1

Views: 2145

Answers (1)

ilir
ilir

Reputation: 3224

You can make an anonymous function that combines the three:

lapply(HierCluster, function(x) tail(sort(colMeans(x))))

Upvotes: 4

Related Questions