Last Updated: February 25, 2016
·
538
· dionysios

Changing Outside Variables in R

In order to change a non-local variable in R, use the <<- operator.
For example if we want to count the number of times a function has been called:

times = 0
testFunction = function(){
    times <<- times + 1
    print(times)
}