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)
}
Written by Dionysios Barmpoutis
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#R
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#