search for: calc_history2

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

Did you mean: calc_history
2006 Jan 23
1
formatC slow? (or how can I make this function faster?
...oblems doing this in a speedy way. The simplest solution (calc_history below, using apply, paste and collapse) takes about 2 seconds for a 10,000 x 10 matrix. I thought perhaps paste might be building up the string in an efficient manner, so I tried using matrix multiplication and formatC (as in calc_history2). This is about 25% faster, but still seems slow. smp <- matrix(rbinom(100000, 1, 0.5), nrow=10000) calc_history <- function(smp) { apply(smp, 1, paste, collapse="") } calc_history <- function(smp) { mul <- 10 ^ ((ncol(smp)-1):0) as.vector(formatC(smp %*% mul, format=&q...