I\'ve got a dataframe dat of size 30000 x 50. I also have a separate list that contains points to groupings of rows from this dataframe, e.g.,
rows <- list(c(
I agree with mathematical coffee that I too get fast times for this.
Don't know if it's possible but by unlisting as a vector and then converting to numeric you can get a speed boost.
dat <- data.frame(matrix(rnorm(30000*50), 30000, 50 ))
rows <- as.numeric(unlist(list(c("34", "36", "39"), c("45", "46"))))
system.time(lapply(rows, function(r) {dat[r, ]}))
EDIT:
dat$observ <- rownames(dat)
rownames(dat) <- 1:nrow(dat)