[R] permutations from vectors out of a matrix
Etienne Stockhausen
einohr2002 at web.de
Mon Jan 18 19:20:16 CET 2010
Dear R-Users,
I'm relativley new to R and have the following problem. I need all
permutations of the vectors created by the collumns of a matrix. I will
give a small example:
p=3
n=2^p-1
#number of obtainable vectors
mat=matrix(0,p,p)
for(i in 1:p)
{
mat[i:1,i]=1/i
}
mat is now a quadratic matrix and n is the number of the vectors I try
to get when I compute all permutations of the vectors built by the
individual columns. It should work for all quadratic matrix and I want
to avoid using some 'special' packages.
In the example I need the following vectors at the end:
(1,0,0); (0,1,0); (0,0,1); (0.5,0.5,0); (0.5,0,0.5); (0,0.5,0.5);
(1/3,1/3,1/3).
I hope my intention becomes clear.
I'm looking foward to any ideas and clues that might help me.
Thanks in advance and best regards.
Etienne
More information about the R-help
mailing list