Thank you so very much! It works like a charm !!! Regards, Laz
On 10/19/2013 5:03 PM, Rui Barradas wrote:
fun <- function(n = 10){ matd <- matrix(sample(1:30,30, replace=FALSE), ncol=5, nrow=6) res <- list(mat = NULL, Design_best = matd, Original_design = matd) trace <- sum(diag(matd)) res$mat <- rbind(res$mat, c(trace = trace, iterations = 0)) for(i in seq_len(n)){ matd <- matrix(sample(1:30,30, replace=FALSE), ncol=5, nrow=6) if(sum(diag(matd)) < trace){ trace <- sum(diag(matd)) res$mat <- rbind(res$mat, c(trace = trace, iterations = i)) res$Design_best <- matd } } res } fun() fun(20)
______________________________________________ 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.