search for: nrowz

Displaying 1 result from an estimated 1 matches for "nrowz".

Did you mean: nrow
2011 Sep 29
1
efficient coding with foreach and bigmemory
...stem.time(look <- foreach(i=1:5e4, .combine=c) %dopar% rnorm(1)) user system elapsed 90.06 0.03 91.20 ===== library(bigmemory) library(foreach) # small data frame that instructs how to fill matrix info <- data.frame(p=c(0.3, 0.5, 0.2), a1=c(100, 200, 80), a2=c(120, 300, 150)) nrowz <- dim(info)[1] # example with small matrix n <- 50 end.i <- cumsum(n*info$p) start.i <- c(0, end.i[-nrowz]) + 1 m <- matrix(NA, nrow=n, ncol=2) for(i in 1:nrowz) { m[start.i[i]:end.i[i], 1] <- runif(n*info$p[i], info$a1[i], info$a2[i]) m[start.i[i]:end.i[i], 2]...