[R] For Loops please help!!
Dan D
ddalthorp at usgs.gov
Sat Sep 5 18:31:40 CEST 2015
Yes, the cause is memory use patterns, but the price is steep nonetheless.
E.g.:
rate<-log(400*1.1^(1:30)) # runs about 27x times as fast as the following
(test via 'microbenchmark')
rate<-numeric(30)
for (i in 1:30){
rate[i]<-log(400*1.1^i)
}
When manipulating large arrays, the difference can easily be a few seconds
vs. an hour or more. And if many such arrays need to be run, the difference
is between "difficult" and "not feasible".
-Dan
--
View this message in context: http://r.789695.n4.nabble.com/For-Loops-please-help-tp4711882p4711887.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list