[R] combinations without repetition
John Fox
jfox at mcmaster.ca
Sun Feb 13 16:33:53 CET 2005
Dear Marcelo,
This is, I guess, permn() in the combinat package.
How about unique(matrix(unlist(permn(c(1,1,0))), ncol=3, byrow=TRUE)), which
leaves the permutations in the rows of a matrix?
I hope this helps,
John
--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox
--------------------------------
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
> mjenny at rumms.uni-mannheim.de
> Sent: Sunday, February 13, 2005 9:45 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] combinations without repetition
>
> The solution is probably simple but I need someone to point me to it.
> How can I reduce the following 6 permutations to the 3 unique
> combinations
> (1,1,0) (1,0,1) (0,1,1)?
>
> permn(c(1,1,0))
> [[1]]
> [1] 1 1 0
>
> [[2]]
> [1] 1 0 1
>
> [[3]]
> [1] 0 1 1
>
> [[4]]
> [1] 0 1 1
>
> [[5]]
> [1] 1 0 1
>
> [[6]]
> [1] 1 1 0
>
> Thanks a lot
> Marcelo Jenny
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list