Subset a data.frame by list and apply function on each part, by rows
- by aL3xa
This may seem as a typical plyr problem, but I have something different in mind.
Here's the function that I want to optimize (skip the for loop).
# dummy data
set.seed(1985)
lst <- list(a=1:10, b=11:15, c=16:20)
m <- matrix(round(runif(200, 1, 7)), 10)
m <- as.data.frame(m)
dfsub <- function(dt, lst, fun) {
# check whether dt is…