Re: [R] Slow function

2008-06-10 Thread Marc
Hi Jim, This is genotype data of 170 samples. I selected subsets of SNP optimized for different types of germplasm. So it is a matrix with 170 rows and 1536, 384 or 96 columns of binary data (0, 1). I have 14 of such matrices in a list. x <- list() for (i in 1:14) { set.seed(i) x[[i]] <- ma

Re: [R] Slow function

2008-06-10 Thread jim holtman
I have no idea of what your data looks like, so using random numbers and only going for nr=1, after about a minute I stopped it. Here is what Rprof showed: /cygdrive/c/perf: perl c:/perf/bin/readRprof.pl Rprof.out 1 0 75.8 root 1. 75.7 sapply 2. . 75.7 lapply 3. . . 75.7 FUN 4. .

Re: [R] Slow function

2008-06-10 Thread jim holtman
first preallocate 'm' to the max (m <- numeric(nr)) and then run Rprof to see where time is being spent. Since there was not reproducible data provided, it is hard to analyze beyond this point. Time is probably being spent in one of the functions On Tue, Jun 10, 2008 at 4:49 AM, Marc <[EMAIL PRO

[R] Slow function

2008-06-10 Thread Marc
Hi, I have the following function that I want to apply to a list of 14 matrices (1536 x 170) of binary data: DRes <- function(x, nr = 1, metric = "mixed", ...) { require(analogue) require(ade4) m <- c() for (i in 1:nr) { set.seed(i) x1 <- x[, sample(dimnames(x)[[2]], length(x[1,]