[R] Permutations

From: Elke Moons <elke.moons_at_uhasselt.be>
Date: Tue, 13 May 2008 09:49:20 +0200


Dear R-users,    

Is there an easy way to determine all possible vectors of length 21 with each entry having permutations from 0 to 4, instead of doing it like this? It really takes up too much time, and I am convinced that there exists something easier.

Can you help me? Thank you in advance!

Kind regards,    

Elke  

for (a in 0:4){

for (b in 0:4){

for (c in 0:4){

for (d in 0:4){

for (e in 0:4){

for (f in 0:4){

for (g in 0:4){

for (h in 0:4){

for (i in 0:4){

for (j in 0:4){

for (k in 0:4){

for (l in 0:4){

for (m in 0:4){

for (n in 0:4){

for (o in 0:4){

for (p in 0:4){

for (q in 0:4){

for (r in 0:4){

for (s in 0:4){

for (u in 0:4){

for (v in 0:4){

vec<-list(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v)

write.table(vec,file="C:/Documents and Settings/My Documents/permutations.txt",sep=";",col.names=FALSE, row.names=FALSE, append=TRUE)

}

}

}

}

}

}

}

}

}

}

}

}

}

}

}

}

}

}

}

}

}
 


Elke Moons, PhD

Transportation Research Institute/

Instituut voor Mobiliteit (IMOB)

Wetenschapspark 1, bus 15

3590 Diepenbeek

BELGIUM Tel. +32-11-26.91.26

Fax. +32-11-26.91.99

E-mail: elke.moons_at_uhasselt.be  

        [[alternative HTML version deleted]]



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. Received on Tue 13 May 2008 - 08:02:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 13 May 2008 - 10:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive