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

2013-08-19 Thread Berend Hasselman
On 19-08-2013, at 18:24, William Dunlap wrote: >> I am a newbie too. I will share what I do normally for speeding up the code. >> >> 1. Restrict defining too many variables (Global/ Local) >> 2. Use apply functions (apply,sapply,lapply,tapply, etc.) whenever feasible >> 3. Having multiple user

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

2013-08-19 Thread William Dunlap
nlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Heramb Gadgil > Sent: Monday, August 19, 2013 8:13 AM > To: Laz > Cc: r-help@r-project.org > Subject:

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

2013-08-19 Thread Heramb Gadgil
Greetings, Thanks Jeff. I appreciate your 'to the point' explanation. Will read into it more. Best, Heramb Gadgil 2013/8/19 Jeff Newmiller > 1. Keeping the number of variables down encourages you to structure your > data, which allows you to re-use code more efficiently. However, I don't > be

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

2013-08-19 Thread Jeff Newmiller
1. Keeping the number of variables down encourages you to structure your data, which allows you to re-use code more efficiently. However, I don't believe that the number of variables intrinsically slows down your code significantly.. e.g. storing a computed value in a local variable is almost al

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

2013-08-19 Thread Heramb Gadgil
Greetings, I am a newbie too. I will share what I do normally for speeding up the code. 1. Restrict defining too many variables (Global/ Local) 2. Use apply functions (apply,sapply,lapply,tapply, etc.) whenever feasible 3. Having multiple user defined functions doesn't help. Try to compact everyt

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

2013-08-19 Thread Laz
Yes Bert, I am a beginner in writing R functions. I just don't know what to avoid or what to use in order to make the R functions faster. When I run the individual functions, they run quite well. However, calling all of them using the final function it becomes too slow. So I don't know how to m

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

2013-08-19 Thread Bert Gunter
... 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. -- Bert On Mon, Aug 19, 2013 at 3:55 AM, Michael Dewey wrote: > At 10:28 19/08/2013, Laz w

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

2013-08-19 Thread Michael Dewey
At 10:28 19/08/2013, Laz wrote: 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. Your example code is rather

[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