[R] permutations in R
dwinsemius at comcast.net
Tue Mar 17 00:16:40 CET 2009
On Mar 16, 2009, at 6:43 PM, Stavros Macrakis wrote:
> Thanks for helping this user.
> I assume you mean the permn function in the combinat package? For a
> new user (including me), it is not obvious how to get from "the
> permutations function in the Combinations package" to that.
> I see there is also a function gtools::permutations. The gtools
> package seems to be more recent than combinat, but I don't know if it
> is better. You might expect a utils::permn since there is a
> utils::combn, but there isn't one....
> I'm not bringing this up because I am bloody-minded, but because I
> think it's a serious issue with the R libraries -- there is no obvious
> way to find relevant functions, and no way of knowing which one to use
> if there is more than one. Or am I missing some trick?
> On Mon, Mar 16, 2009 at 3:26 PM, Greg Snow <Greg.Snow at imail.org>
>> Look at the permutations function in the Combinations package.
>> Using the "fun" argument may accomplish what you want. If not,
>> there are references on the help page to other code that may work
>> for you.
>> Hope this helps,
>> Gregory (Greg) L. Snow Ph.D.
>> Statistical Data Center
>> Intermountain Healthcare
>> greg.snow at imail.org
>>> -----Original Message-----
>>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>>> project.org] On Behalf Of onyourmark
>>> Sent: Friday, March 13, 2009 7:09 PM
>>> To: r-help at r-project.org
>>> Subject: [R] permutations in R
>>> Hi. Does anyone know of a function which will take as input a
>>> number n
>>> (or a
>>> set of n letters) and will give out, one at a time, the
>>> permutations of
>>> (or of those n letters) as a vector?
>>> So that I can use the permutations one at a time. And such that it
>>> exhaust all the permutations with no repeats.
>>> For example if n is 3, I would want a function which I could use
>>> in a
>>> and the first time I use it in the loop it may give the vector
>>> and then the next time in the loop it may give
>>> and so on until after 6 iterations through the loop I would get
>>> all 6
>>> permutations of 123.
>>> Thank you.
>>> View this message in context: http://www.nabble.com/permutations-in-R-
>>> Sent from the R help mailing list archive at Nabble.com.
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide http://www.R-project.org/posting-
>>> and provide commented, minimal, self-contained, reproducible code.
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help