gusl: (Default)
[personal profile] gusl
R'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.

> m <- 5
> f <- function(){ m <<- 10 }
> 
> m
[1] 5
> f()
> m
[1] 10
(will be screened)
(will be screened if not validated)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

February 2020

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags