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

Mark Wardle mark at wardle.org
Mon Jan 14 08:38:16 CET 2008

On 14/01/2008, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> Its not related to scoping. f(b = 10) passes 10 as argument b
> but f(b <- 10) assigns to variable b (which has nothing to do with
> argument b) and then passes the result of the b<-10 expression (which is
> 10) to f.  Since no argument was specified it uses positional
> matching and the first position is argument a.  Thus its the same
> as f(10).  Note that f(b<-10) isthe same as f( (b <- 10) ) which may
> make it clearer.

Of course! Straightforward!

Many thanks,


Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

More information about the R-help mailing list