I have only achieved a half improvement. x <- array(1:24000000*1, dim = c(200,300,400)) y <- 1:400*1 ptm <- proc.time() z <- x*as.vector(t(replicate(dim(x)[1]*dim(x)[2], y[1:dim(x)[3]]))) "replicate:" proc.time() - ptm
x <- array(1:24000000*1, dim = c(200,300,400)) y <- 1:400*1 ptm <- proc.time() z <- x*rep(y[1:dim(x)[3]],each=dim(x)[1]*dim(x)[2]) "rep:" proc.time() - ptm ----- A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Multiply-each-depth-level-of-an-array-with-another-vector-element-tp2315537p2315860.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.