[R] Non repetitive permutations/combinations of elements

Nameeta Lobo nlobo at bsd.uchicago.edu
Mon May 8 23:32:59 CEST 2006


Hello all,

I am trying to create a matrix of 1s and -1s without any repetitions for a
specified number of columns.
e.g. 1s and -1s for 3 columns can be done uniquely in 2^3 ways.
-1 -1 -1
-1 -1  1
-1  1 -1
-1  1  1
 1 -1 -1
 1 -1  1
 1  1 -1
 1  1  1
and for 4 columns in 2^4 ways and so on.

I finally used the function combn([0 1],3) that I found at the following link
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=7147&objectType=FILE
written by Jos van der Geest in Matlab which generated the above.


How can I do this is R? I have looked at permn and combn in the combinat library
and permutations and combinations in the gtools library and I am still confused
as to how to get it to work.

Any suggestions will be truly appreciated.

Thank you

Nameeta



-------------------------------------------------
This email is intended only for the use of the individual or...{{dropped}}




More information about the R-help mailing list