[R] For Loop

rsherry8 r@herry8 @ending from comc@@t@net
Sat Sep 22 23:16:27 CEST 2018


It is my impression that good R programmers make very little use of the 
for statement. Please consider  the following
R statement:
         for( i in 1:(len-1) )  s[i] = log(c1[i+1]/c1[i], base = exp(1) )
One problem I have found with this statement is that s must exist before 
the statement is run. Can it be written without using a for
loop? Would that be better?

Thanks,
Bob



More information about the R-help mailing list