## colwiseProd
X <- matrix(1:16, nrow=4)
v <- 1:4
t(v * t(X))
colwiseProd(v, X)
if (FALSE) {
system.time(for (ii in 1:100000) t(v * t(X)))
system.time(for (ii in 1:100000) colwiseProd(v, X))
}
setlist <- list(c(1,2,3), c(2,3,4), c(2,4,5))
item <- c(2,3)
lapplyV2I(setlist, item)
lapply(setlist, function(gg) match(gg, item))
lapplyI2V(setlist, item)
lapply(setlist, function(x) item[x])
if (require(microbenchmark)){
microbenchmark(
lapplyV2I(setlist, item),
lapply(setlist, function(elt) match(elt, item)))
microbenchmark::microbenchmark(
lapplyI2V(setlist, item),
lapply(setlist, function(elt) item[elt]))
}
Run the code above in your browser using DataLab