Is it possible to get a vector or list of variables in an expression?
For instance:
e <- expression(2 * x^2 + y)
The desired output:
('x', 'y')
Is it possible? Or is it necessary to input variable names manually?
Is it possible to get a vector or list of variables in an expression?
For instance:
e <- expression(2 * x^2 + y)
The desired output:
('x', 'y')
Is it possible? Or is it necessary to input variable names manually?
Use all.vars
:
all.vars(e)
[1] "x" "y"