Skip to content
Prev 205534 / 398506 Next

Increment in loop

useRs,

I'm getting limited success in trying to apply increment in a loop.

The following defined function creates a +1 increment

incr <- function(x){
eval.parent(substitute(x <- x + 1))
print(x) }

How do I apply it in a loop on my test dataset, x1, so that the procedure becomes

x1[c(1:2)]
x1[c(2:3)]
x1[c(3:4)]

where x1 =
Thanks.


Muhammad