Re: [R] combinations/ indexing a matrix

2010-03-11 Thread RICHARD M. HEIBERGER
res <- combn(4,2) result <- LETTERS[res] dim(result) <- dim(res) result ## Rich [[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] combinations/ indexing a matrix

2010-03-11 Thread Michael Friendly
For a package application, I want to generate all 1-way, or 2-way, ... combinations of factors, symbolically, as a matrix. E.g., all two-way terms among 4 factors. > factors <- LETTERS[1:4] > combn(4,2) [,1] [,2] [,3] [,4] [,5] [,6] [1,]111223 [2,]2343