Re: [R] Two matrix loop

2011-03-26 Thread Thomas Levine
This way uses a three-dimensional array instead of the nested apply. It seems to take the same amount of time, even on larger datasets, but it may give you ideas. distance=function(x) daisy(x, metric = 'gower') persons=array(dim=c(2,nrow(donor)*nrow(receiver),ncol(receiver))) persons[1,,]=donor[r

[R] Two matrix loop

2011-03-24 Thread Stefan Petersson
Hi, I'm trying to create a distance matrix. And it works out somewhat ok. However, I suspect that there are some efficiency issues with my efforts. Plz have a look at this: donor <- matrix(c(3,1,2,3,3,1,4,3,5,1,3,2), ncol=4) receiver <- matrix(c(1,4,3,2,4,3,1,5,1,3,2,1,4,5,3,5,1,3,2,4,5,1,2,3