Re: [R] loop not working my way

2013-10-20 Thread Rui Barradas
Hello, Make a _simple_ example, I don't see what packages like knitr or ggplot2 have anything to do with your problem. Like this is, I think you're asking too much from r-help. Rui Barradas Em 19-10-2013 23:38, Laz escreveu: Dear R users, Dear R users, (I had not included two more function

Re: [R] loop not working my way

2013-10-19 Thread Laz
Dear R users, Dear R users, (I had not included two more functions in the previous mail. This version is complete) There is a small problem which I don't know how to sort it out, based on the former example I had explained earlier own. I am calling my own functions which are based on simulat

Re: [R] loop not working my way

2013-10-19 Thread Laz
Dear R users, There is a small problem which I don't know how to sort it out, based on the former example I had explained earlier own. I am calling my own three functions which are based on simulations as below: library(gmp) library(knitr) # load this packages for publishing results library(mat

Re: [R] loop not working my way

2013-10-19 Thread Laz
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(mat

Re: [R] loop not working my way

2013-10-19 Thread Rui Barradas
Hello, Seems simple. 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))

[R] loop not working my way

2013-10-19 Thread laz
Dear R users, Suppose I want to randomly generate some data, in matrix form, randomly swap some of the elements and calculate trace of the matrix for each of these stages. If the value of trace obtained in the later is bigger than the former, drop the latter matrix and go back to the former ma