R expression variable list

expression, r, variables

Solution

Use `all.vars`:

all.vars(e)
[1] "x" "y"

Problem

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?

Original source