Thanks for all the suggestions. This is my final code that seems to be
working:

alphabet = c("a","b","c","d")
holder = c()
permute = function(alphabet,n){
while((length(unique(holder))/n)<(length(alphabet)^n)){
    perm = sample(alphabet, replace=T, size=n)
    holder = rbind(holder, perm, deparse.level=0)
}
data2 = unique(holder)
data3 = data2[order(data2[,1],data2[,2]),]
labels = apply(data3, 1, paste, sep="", collapse="")
print(data.frame(data3, row.names=labels))
}

Is this an efficient enough method?

--
View this message in context: 
http://r.789695.n4.nabble.com/Writing-a-Permutation-Function-tp4594621p4596297.html
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.

Reply via email to