[R] Slow function

From: Marc <marc.moragues_at_gmail.com>
Date: Tue, 10 Jun 2008 09:49:23 +0100


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 = 10000, 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,])/2)]
    x2 <- x[, !dimnames(x)[[2]] %in% dimnames(x1)[[2]]]
    d1 <- as.dist(distance(as.data.frame(x1), method = metric))
    d2 <- as.dist(distance(as.data.frame(x2), method = metric))
    m[i] <- mantel.rtest(d1, d2, ...)$obs     mean <- mean(m)
    std <- sd(m)
    res <- list(mean = mean, std = std)
  }
  return(res)
}
bias.dres <- sapply(bias, DRes)

I run this code and after 3 hours is still running. I am on Windows XP and this is my sessionInfo()
> sessionInfo()

R version 2.7.0 Patched (2008-05-02 r45580) i386-pc-mingw32

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] analogue_0.5-1 vegan_1.11-4 ade4_1.4-7

Any help will be very much appreciated.
Marc.



R-help_at_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. Received on Tue 10 Jun 2008 - 08:54:25 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 Jun 2008 - 10:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive