roger chan
2007-Oct-27 20:08 UTC
[R] How to generate all permutation of 0-1 sequences in R?
Hi, folks: I need to generate all 0-1 sequences with given length,say,n=3, the ideal result would be the following matrix: 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 Any help would be appreciated. -- View this message in context: http://www.nabble.com/How-to-generate-all-permutation-of-0-1-sequences-in-R--tf4704377.html#a13446919 Sent from the R help mailing list archive at Nabble.com.
Henrique Dallazuanna
2007-Oct-27 20:18 UTC
[R] How to generate all permutation of 0-1 sequences in R?
Hi, expand.grid(x=c(0,1), y=c(0,1), z=c(0,1)) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 27/10/2007, roger chan <rogerchan2006@gmail.com> wrote:> > > Hi, folks: > > I need to generate all 0-1 sequences with given length,say,n=3, the ideal > result would be > the following matrix: > > 0 0 0 > 0 0 1 > 0 1 0 > 0 1 1 > 1 0 0 > 1 0 1 > 1 1 0 > 1 1 1 > > > Any help would be appreciated. > -- > View this message in context: > http://www.nabble.com/How-to-generate-all-permutation-of-0-1-sequences-in-R--tf4704377.html#a13446919 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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]]
Gabor Csardi
2007-Oct-27 20:21 UTC
[R] How to generate all permutation of 0-1 sequences in R?
library(combinat) hcube( rep(2,3) ) -1 Here n=3. Gabor On Sat, Oct 27, 2007 at 01:08:07PM -0700, roger chan wrote:> > Hi, folks: > > I need to generate all 0-1 sequences with given length,say,n=3, the ideal > result would be > the following matrix: > > 0 0 0 > 0 0 1 > 0 1 0 > 0 1 1 > 1 0 0 > 1 0 1 > 1 1 0 > 1 1 1 > > > Any help would be appreciated. > -- > View this message in context: http://www.nabble.com/How-to-generate-all-permutation-of-0-1-sequences-in-R--tf4704377.html#a13446919 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.-- Csardi Gabor <csardi at rmki.kfki.hu> MTA RMKI, ELTE TTK