outer() generally works by expanding out the lists like


Y <- rep(y,length(x))
X <- rep(x,each=length(y)) # or maybe it's vice versa, never mind...
FUN(X,Y,extras)

and then adds dims and dimnames. If FUN vectorizes, this is the
efficient way, but it does not in your case and the rep()s are
probably not cheap when lists are involved.

you might try this sort of stuff:

myfunc2 <- function(i,j)
mapply(function(i,j)
phylo.overlap(assemblages[[i]],assemblages[[j]],parrot.cm),
i,j)
ind <- seq(along=assemblages)
outer(ind,ind,myfunc2)



That now runs at about the same speed as the loops (although the loops still just have the edge).


Many thanks for the suggestions.

David

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to