Hi Jason, Thanks for you suggestions, I think that's pretty close to what I'd need. The only glitch is that I'd be working with a vector of ~30 elements, so permutations(...) would take quite a long time. I only need one permutation per vector (the whole routine will be within a loop that generates pseudo-random vectors that could potentially conform to the constraints).
In light of that, do you think I'd be better off doing something like: v.permutations <- replicate(10000,sample(v,length(v),rep=FALSE)) # instead of permutations(....) results <- apply(v.permutations,2,function(x){all(x <= f(x[1],length(x)-1))}) # function f(...) would be like your f It wouldn't be guaranteed to produce any usable permutation, but it seems like it would be much faster and so could be repeated until an acceptable vector is found. What do you think? Thanks-- Andy On Thu, Jan 28, 2010 at 6:15 AM, Jason Smith <devja...@gmail.com> wrote: > I just realized I read through your email too quickly and my script does > not actually address the constraint on each permutation, sorry about that. > > You should be able to use the permutations function to generate the vector > permutations however. > > Jason > > ______________________________________________ > 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. > [[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.