[R] For Loops please help!!

Dan D ddalthorp at usgs.gov
Sat Sep 5 17:31:15 CEST 2015


Also, any time you write "for" in R, you pay a steep price in performance. In
a short, simple loop it may not be noticeable, but in a more challenging
problem it can be a huge issue.

A more efficient way to write your loop would be:
infectrate = 400*1.1^(1:30) # calculation
cbind(1:30,log(infectrate))    # display

-Dan



--
View this message in context: http://r.789695.n4.nabble.com/For-Loops-please-help-tp4711882p4711885.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list