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

2014-06-18 Thread Laz
19 73 1 13 328 79 1 14 310 --truncated Regards, Laz [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

[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 *

[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

[R] loop not working my way

2013-10-19 Thread laz
] [,3] [,4] [,5] [1,] 12 27 29 16 19 [2,] 25 107 22 13 [3,] 14 233 11 21 [4,] 28652 18 [5,] 24 201 17 26 [6,]94 308 15 Regards, Laz __ R-help@r-project.org mailing list https

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(matd

Re: [R] loop not working my way

2013-10-19 Thread Laz
[1] 2 3 4 5 6 7 10 11 13 14 15 16 ## I expect a maximum of 8 changes but I 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:09 PM, Laz wrote: Thank you so

Re: [R] loop not working my way

2013-10-19 Thread Laz
) Hope this helps, Rui Barradas Em 19-10-2013 18:41, laz escreveu: 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

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. Jim Holtman

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

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 here? Regards, Laz On 9/22/2013 4:21 PM

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]

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

2013-09-21 Thread Laz
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 PLEASE do read the posting guide http://www.R

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

2013-09-21 Thread Laz
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 PLEASE do read the posting guide http://www.R

[R] Error in Loop

2013-09-14 Thread Laz
(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]] __ R-help@r

[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] How can I make my functions run faster

2013-08-19 Thread Laz
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, well-structured R code

Re: [R] R help on loops

2013-06-07 Thread Laz
3 [4,]46 [5,]28 [6,]2 17 On Fri, May 31, 2013 at 2:02 PM, Laz lmra...@ufl.edu mailto:lmra...@ufl.edu wrote: 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

Re: [R] R help on loops

2013-06-07 Thread Laz
Hasselman wrote: On 07-06-2013, at 10:59, Laz lmra...@ufl.edu 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

Re: [R] R help on loops

2013-06-07 Thread Laz
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 lmra...@ufl.edu wrote: Dear R users, I am stuck here: My first function returns a vector of 5 values. In my second

[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