R's superassignment operator
Oct. 1st, 2009 02:22 amR's assignment operator is "<-". Typically, R functions do not have side-effects... whenever you refer to an outside variable inside a function, what you're seeing is a copy, shadowing the original... which means that you should return all the information you want to keep.
However, I just discovered that there is a superassignment operator, "<<-", which enables side-effects.
However, I just discovered that there is a superassignment operator, "<<-", which enables side-effects.
> m <- 5
> f <- function(){ m <<- 10 }
>
> m
[1] 5
> f()
> m
[1] 10