Hacker News new | ask | show | jobs
by Lanrei 2610 days ago
Shouldn't '<-' be used instead of '=' for variable assignments, as they aren't the same thing in R.
2 comments

It's a large source of bike-shedding in the R community but out of the 5 assignment operators in R, those two are largely the same.

There's a good explanation here: https://stackoverflow.com/questions/1741820/what-are-the-dif...

They are the same thing, minus the corner case of assignment within a function call:

e.g.

  divide = function(x, y) {
    return(x/y)
  }

  divide(y = 2, x = 1)
  divide(y <- 1, x <- 2)

These two calls give the same result, as the second results in assignment and then passing the argument by position. Other than this case, they are exactly interchangeable.