In python you can do something like this:
x,y = 1,2
or
x,y = function_that_returns_two_elements()
I was trying to do something similar in R but found no solution. Is it possible?
In python you can do something like this:
x,y = 1,2
or
x,y = function_that_returns_two_elements()
I was trying to do something similar in R but found no solution. Is it possible?
We can use multiple assignment operator (%=%
) for this
library(collapse)
c("x", "y") %=% c(1,2)
-output
> x
[1] 1
> y
[1] 2
If it should be unquoted
rm(x, y) # remove the objects from the global environment
.c(x, y) %=% c(1, 2)
-output
> x
[1] 1
> y
[1] 2