Dear all, I want to apply a function to list elements, two by two. I hoped that combn would help me out, but I can't get it to work. A nested for-loop works, but seems highly inefficient when you have large lists. Is there a more efficient way of approaching this?
# Make some toy data data(iris) test <- vector("list",3) for (i in 1:3){ x <- levels(iris$Species)[i] tmp <- dist(iris[iris$Species==x,-5]) test[[i]] <- tmp } names(test) <- levels(iris$Species) # nested for loop works for(i in 1:2){ for(j in (i+1):3){ print(all.equal(test[[i]],test[[j]])) } } # combn doesn't work combn(test,2,all.equal) Cheers Joris -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] ______________________________________________ R-help@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.