Re: [R] Working with combinations

2010-03-06 Thread Herm Walsh
out of x here. selectedSet <- NULL while (!is.na(currCombin)){    if( #*** currCombin passes test ***#   ) {       selectedSet <- rbind(selectedSet,currCombin)    }  currCombin <- next.combin(currCombin,5) #here we say that we want 2 out of 5  } On Mar 6, 2010, at 5:54 PM, Herm Walsh w

Re: [R] Working with combinations

2010-03-06 Thread Herm Walsh
b) } last.hole.pos <- function(comb,n){   lcomb <- length(comb)   diffs <- comb[-1]-comb[-lcomb]   if (max(diffs)==1) { return(lcomb)   }    diffpos <- which(diffs>1)   return(diffpos[length(diffpos)])       } On Mar 3, 2010, at 7:35 PM, Herm Walsh wrote: Thanks David for the thoughts.  The c

Re: [R] Working with combinations

2010-03-03 Thread Herm Walsh
Thanks David for the thoughts.  The challenge I have with this approach is that the criteria I have is defined by a series of tests--which I do not think I could substitute in in place of the logical indexing. In the combinations code I was hoping there is a step where, each new combination is

[R] Working with combinations

2010-03-02 Thread Herm Walsh
I am working with the combinations function (available in the gtools package).  However, rather than store all of the possible combinations I would like to check each combination to see if it meets a certain criteria.  If it does, I will then store it. I have looked at the combinations code but