Extracts the variable names from an R expression by pre- and post-processing
around all.vars()
.
First replaces $
with [[
indexing, so that internal column/variable names
are ignored, then calls all.vars()
.
Usage
bru_used_vars(x, functions = FALSE)
# S3 method for class 'character'
bru_used_vars(x, functions = FALSE)
# S3 method for class 'expression'
bru_used_vars(x, functions = FALSE)
# S3 method for class 'formula'
bru_used_vars(x, functions = FALSE)
See also
Other bru_used:
bru_used()
,
bru_used_update()
Examples
bru_used_vars(~.)
#> NULL
bru_used_vars(~ a + b + c_latent + d_eval())
#> [1] "a" "b" "c_latent"
bru_used_vars(expression(a + b + c_latent + d_eval()))
#> [1] "a" "b" "c_latent"
bru_used_vars(~., functions = TRUE)
#> NULL
bru_used_vars(~ a + b + c_latent + d_eval(), functions = TRUE)
#> [1] "+" "a" "b" "c_latent" "d_eval"
bru_used_vars(expression(a + b + c_latent + d_eval()), functions = TRUE)
#> [1] "expression" "+" "a" "b" "c_latent"
#> [6] "d_eval"
bru_used_vars(a ~ b)
#> [1] "b"
bru_used_vars(expression(a ~ b))
#> [1] "a" "b"