[R] How to optimize this loop ? (correction)
Martin Becker
martin.becker at mx.uni-saarland.de
Thu Jan 18 15:22:07 CET 2007
Sorry, I accidentaly lost one line of the function code (result <-0),
see below...
Regards, Martin
Martin Becker schrieb:
>
> myfun1 <- function(series=c(3, 4, 10,14,8,3,4,6,9)) {
result <- 0 # NEW
> len<-length(series)
> for (i in (len-1):1)
> {
> if (series[i]>series[len])
> { result <- i-1 ; break }
> }
> return(result)
> }
>
...
More information about the R-help
mailing list