[R] is it safe to replace every "<-" by "=" in R code?

Peter Danenberg danenberg at post.harvard.edu
Mon Jan 14 08:31:52 CET 2008


Quoth Mark Wardle on Prickle-Prickle, Chaos 14, 3174:
> I can see that f(b <- 10) is equivalent to f(assign("b"), 10))

f(assign("b", 10))?

My undestanding is that assign applies to the parental environment;
but the return value of assign, namely 10, is passed to f as the local
variable a.

The default value b = 4 then overrides the parental environment since
it is unspecified in the call to f.




More information about the R-help mailing list