8vcvca
Last Updated: February 25, 2016
·
335
· dionysios
083618effe3fca9cd4ecc895809833a8

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)
}
Say Thanks
Respond