[R] How can I avoid the for and If loops in my function?

2014-06-18 Thread Laz
3 1 8 222 49 1 9 2 3 55 1 10 226 61 1 11 318 67 1 12 319 73 1 13 328 79 1 14 310 --truncated Regards, Laz [[alternative HTML version deleted]] __

[R] help in writing an R-function for Residual correlated structures

2014-06-12 Thread Laz
Hi R users, I need to write a function that considers the row and column autoregressive residual correlation structures. Usually R=sigma^2_e*Identity matrix of order n, where n is the number of observations and sigma^2_e is the usual residual error. I have to consider an AR1 * AR1 where * stan

[R] Adding correlation and or variance structure in mixed models

2014-04-07 Thread Laz
model that has both fixed and several random effects. Which R packages or functions will help me to accomplish this? Thanks. Laz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

Re: [R] loop not working my way

2013-10-19 Thread Laz
get 12 changes which means that function only dropped the traces when trace_j > trace_i but did not drop the design !! How do I fix this ? Kind regards, lazarus On 10/19/2013 5:03 PM, Rui Barradas wrote: > Hello, > > Seems simple. > > > fun <- function(n = 10){ >

Re: [R] loop not working my way

2013-10-19 Thread Laz
seq_len(n)){ # now swap the pairs of treatments from the original design, n times matdf<-swapsimple(matdf,ped="F") if(mainF(criteria="A") < start0){ start0<- mainF(criteria="A") res$mat <- rbind(res$mat, c(trace = start0

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 &l

[R] loop not working my way

2013-10-19 Thread laz
29 [4,] 30 20 177 23 [5,] 18 27 211 10 [6,] 25 1648 26 $ Original_design [,1] [,2] [,3] [,4] [,5] [1,] 12 27 29 16 19 [2,] 25 107 22 13 [3,] 14 233 11 21 [4,] 28 652 18 [5,] 24 201 17 26 [6,]

Re: [R] Creating rectangular plots with x and y coordinates and treatments from a matrix for a randomized block design

2013-09-23 Thread Laz
Thanks. Sweave/Latex is done the job for me ! Regards, Laz On 9/22/2013 8:26 PM, jim holtman wrote: CHeck out the 'tables' package if you want to create pretty outputs of your tables. Exactly where do you plan to use them? You can also use Sweave/Latex to create such tables. J

Re: [R] Creating rectangular plots with x and y coordinates and treatments from a matrix for a randomized block design

2013-09-22 Thread Laz
Hi, fortune("Yoda") returns a quote of fortunes. My problem was to draw horizontal and vertical lines to separate the blocks in my design. Each block has 4 elements. The first and second rows and columns are in block 1, 3rd and 4th rows and 1st and 2nd columns are in 3 etc [,1] [,2] [,

Re: [R] Creating rectangular plots with x and y coordinates and treatments from a matrix for a randomized block design

2013-09-22 Thread Laz
Is "Yoda" an R package? I tried: install.packages("Yoda") Warning in install.packages : package 'Yoda' is not available (for R version 3.0.1) Warning in install.packages : package 'Yoda' is not available (for R version 3.0.1) How do I proceed from h

Re: [R] Creating rectangular plots with x and y coordinates and treatments from a matrix for a randomized block design

2013-09-22 Thread Laz
Thanks Jim, What you have done is very good. I was wondering if we could draw some horizontal and vertical lines to separate the blocks. Is it possible using R? Regards, Laz On 9/22/2013 11:10 AM, jim holtman wrote: Is this what you were after: ## A function to generate a RCB design rcbd

[R] Creating rectangular plots with x and y coordinates and treatments from a matrix for a randomized block design

2013-09-21 Thread Laz
ction? 2 4 2 3 1 3 4 1 3 2 2 3 1 4 4 1 Regards, Laz [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-h

[R] Creating rectangular plots with x and y coordinates and treatments from a matrix for a randomized block design

2013-09-21 Thread Laz
ction? 2 4 2 3 1 3 4 1 3 2 2 3 1 4 4 1 Regards, Laz [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help P

[R] Error in Loop

2013-09-14 Thread Laz
to delete delete <- which.max(high) + 1L mat <- mat[-delete,, drop=FALSE] } The error I get is " Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] : non-numeric argument to binary operator" How do I fix it? Laz [[alternative HTML version deleted]] __

Re: [R] How can I make my functions run faster

2013-08-19 Thread Laz
now how to make it faster. I used system.time() Regards, Laz On 8/19/2013 10:13 AM, Bert Gunter wrote: ... and read the "R Language Definition" manual. I noticed unnecessary constructs (e.g., z <- f(something); return(z)) that suggest you have more basics to learn to write efficient,

[R] How can I make my functions run faster

2013-08-19 Thread Laz
Dear R users, I have written a couple of R functions, some are through the help of the R group members. However, running them takes days instead of minutes or a few hours. I am wondering whether there is a quick way of doing that. Here are all my R functions. The last one calls almost all of

Re: [R] R help on loops

2013-06-07 Thread Laz
.8890167 0.884659 0.0004215379 0.000410769 0.2342 0.676307 0.8885839 0.0001215379 0.0002112 0.82752992 0.8836337 Thanks fpr you help. On 6/7/2013 5:24 AM, Berend Hasselman wrote: > On 07-06-2013, at 10:59, Laz wrote: > >> Dear R users, >> >> I am stuck

Re: [R] R help on loops

2013-06-07 Thread Laz
Hasselman wrote: On 07-06-2013, at 10:59, Laz wrote: Dear R users, I am stuck here: My first function returns a vector of 5 values. In my second function, I want to repeat this, a number of times, say 10 so that I have 10 rows and five columns but I keep on getting errors. See the code and results

Re: [R] R help on loops

2013-06-07 Thread Laz
5 > [6,]46 > [7,] 117 > [8,]28 > [9,]69 > [10,]5 10 > [11,]6 11 > [12,] 18 12 > [13,]9 13 > [14,] 16 14 > [15,] 18 15 > [16,]9 16 > [17,]2 17 > [18,]7 18 > [19,] 15 19

[R] R help on loops

2013-05-31 Thread Laz
Dear R Users, I created a function which returns a value every time it's run (A simplified toy example is attached on this mail). For example spat(a,b,c,d) # run the first time and it gives you ans1= 10, perm=1 ; run the second time and gives you ans2= 7, perm=2 etc I store both the result