0

I recently discovered that R allows chaining of assignments, e.g.

a = b = 1:10
a
 [1]  1  2  3  4  5  6  7  8  9 10
b
 [1]  1  2  3  4  5  6  7  8  9 10

I then thought that this could also be used in functions, if two arguments should take the same value. However, this was not the case. For example, plot(x = y = 1:10) produces the following error: Error: unexpected '=' in "plot(x = y =". What is different, and why doesn't this work? I am guessing this has something to with only the first being returned to the function, but both seem to be evaluated.

What are some possibilities and constraints with chained assignments in R?

mhovd
  • 2,814
  • 2
  • 16
  • 35

0 Answers0