[R] How to make R faster?

Spencer Graves spencer.graves at pdf.com
Tue Jan 25 22:26:15 CET 2005


      My standard algorithm for improving speed is as follows: 

      1.  Identify what takes the most time. 

      2.  Try to find ways in R to speed it up, e.g., converting loops 
to vector operations.  Many tasks in R can be performed in a variety of 
different ways to get the same result but with different time. 

      3.  If that fails, convert the most time consuming part into 
compiled code and link to it. 

      Use "system.time" to time a single expression and "proc.time" to 
store the time at multiple places in your code;  precede any test with 
garbage collection (gc) to reduce variations in the answers. 

      An "R site search" (www.r-project.org -> Search -> "R site 
search") for "timing R" produced 126 hits, the second of which gave 
"system.time";  you might skim the rest for other ideas.  A similar 
search for "compute speed" produced 64 hits, some of which will 
doubtless interest you if you haven't already read them. 

      For more help on this, please be more specific, e.g., following 
the posting guide! "http://www.R-project.org/posting-guide.html". 

      hope this helps.  spencer graves

ebashi wrote:

>Dear R users;
>I am using R for a project. I have some PHP forms that
>pass parameters to R for calculations, and publish the
>result in HTML format by CGIwithR. I'm using a Linux
>machine and every things work perfectly. However, it
>is  too slow, it takes 5 to 10 seconds to run, and
>even  if I start R from the Shell it takes the same
>amount of time, which is probably due to installing
>packages. My first question is that how can i make R
>run faster? and second if I am supposed to reduce the
>packages which are being loaded at initiation of R,
>how can I limit it to only the packages that i want?
>and third how can i make R not to get open each time,
>and let it sit on the server so that, when i pass
>something to it , i get result faster?
>
>Sincerely,
>Sean
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>




More information about the R-help mailing list