Re: [R] How to increase the for() loop speed?

From: Erik Iverson <iverson_at_biostat.wisc.edu>
Date: Thu, 12 Jun 2008 11:46:09 -0500

We would certainly need more information about your function to offer any specific advice, therefore I'll fall back on the general. First there is no command that will increase a for loop speed, it is not as if they are artificially slowed down.

In general, you may be able to do whatever it is you are doing using vectorized calculations instead of looping, and/or by using a combination of the *apply functions.

You should read the latest issue of R News, as it has an article related to your question, and will explain my paragraphs above. Find it here,

http://cran.r-project.org/doc/Rnews/

Finally, there is a special mailing list for using R for quantitative finance, perhaps you could a more detailed question there, search for R-SIG-Finance.

Erik

Rafael Barros de Rezende wrote:
> My routine is on Financial Econometrics (Yield Curve Modeling). It is
> very intensive. And I have heard that the for() loop speed could be
> increased with a command. I want to know if there a way to do it.
>
> Best regards.
>
> Rafael Barros de Rezende
>
>
>
> *---------- Original Message -----------*
> From: Erik Iverson <iverson_at_biostat.wisc.edu>
> To: Rafael Barros de Rezende <rafabarros_at_cedeplar.ufmg.br>
> Cc: r-help_at_r-project.org
> Sent: Thu, 12 Jun 2008 11:06:09 -0500
> Subject: Re: [R] How to increase the for() loop speed?
>
> > 13 minutes is a long time for a loop to simply send an email, what other
> > calculations are going on?
> >
> > Rafael Barros de Rezende wrote:
> > > Dear R users,
> > >
> > > I would like to know if there is a way to increase the for()
> loop speed
> > > because in my routine the calculations are too slow.
> > >
> > > Best regards.
> > > Rafael Barros de Rezende
> > > Cedeplar - Center for Development and Regional Planning
> > > Face, UFMG ([1]http://www.cedeplar.ufmg.br
> <http://www.cedeplar.ufmg.br/>)
> > > --
> > > Esta mensagem foi verificada pelo sistema de antivĂ­rus e
> > > acredita-se estar livre de perigo.
> > >
> > > References
> > >
> > > 1. http://www.cedeplar.ufmg.br/
> > > ______________________________________________
> > > R-help_at_r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> <http://www.r-project.org/posting-guide.html>
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
> > --
> > Esta mensagem foi verificada pelo sistema de antivírus e
> > acredita-se estar livre de perigo.
> *------- End of Original Message -------*
>
>
> --
> Esta mensagem foi verificada pelo sistema de antivírus e
> acredita-se estar livre de perigo.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 12 Jun 2008 - 17:01:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 12 Jun 2008 - 18:30:40 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive