search for: outvector

Displaying 1 result from an estimated 1 matches for "outvector".

2006 Oct 24
4
avoiding a loop
...e function below can be rewritten without a for loop. apply is fine if it can be done that way but i doubt it. I call it a lot and would prefer to not loop. #----------------------------------------------------------------------- -------------------------- constructLt<-function(invector) { outvector<-invector for ( i in 2:length(invector) ) { if ( invector[i] < 1 ) { outvector[i]<-invector[i]*outvector[i-1] } } return(outvector) } #----------------------------------------------------------------------- ------------------------- ---------------------------------------------...