Try this
lapply(my.ls, "[", ,c(1,3))
Or editing a little bit your code yields:
lapply(my.ls, function(x) x[, c(1,3)])
Edit
Since @Matthew Plourde already answered the second part of your question using lapply
, then I give you an alternative way to do it using rapply
which is the recursive version of lapply
.
rapply(lapply(my.ls, "[", ,c(1,3)), unique, how="list")