[R] Fixed size permutations

2010-01-14 Thread Nick Fankhauser
I'm using functions to return a matrix of all permutations of a specified size from a larger list for predictor selection. For each predictor size I use a seperate function like this: bag2 - function(n) { rl - c() for (i1 in seq(n)) { for (i2 in seq(n)) { if

Re: [R] Fixed size permutations

2010-01-14 Thread Peter Ehlers
Nick Fankhauser wrote: I'm using functions to return a matrix of all permutations of a specified size from a larger list for predictor selection. For each predictor size I use a seperate function like this: bag2 - function(n) { rl - c() for (i1 in seq(n)) { for (i2 in seq(n)) {

Re: [R] Fixed size permutations

2010-01-14 Thread Henrique Dallazuanna
Try this: v - 1:5 n - 2 t(subset(do.call(expand.grid, replicate(n, v, FALSE))[n:1], Var1 != Var2)) On Thu, Jan 14, 2010 at 9:51 AM, Nick Fankhauser li...@nyk.ch wrote: I'm using functions to return a matrix of all permutations of a specified size from a larger list for predictor selection.

Re: [R] Fixed size permutations

2010-01-14 Thread Peter Ehlers
Small modification below. Peter Ehlers wrote: Nick Fankhauser wrote: I'm using functions to return a matrix of all permutations of a specified size from a larger list for predictor selection. For each predictor size I use a seperate function like this: bag2 - function(n) { rl - c()