Learn R Programming

inlabru (version 2.11.1)

bru_used_vars: Extract basic variable names from expression

Description

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 character bru_used_vars(x, functions = FALSE)

# S3 method for expression bru_used_vars(x, functions = FALSE)

# S3 method for formula bru_used_vars(x, functions = FALSE)

Value

If successful, a character vector, otherwise NULL

Arguments

x

A formula, expression, or character

functions

logical; if TRUE, include function names

Methods (by class)

  • bru_used_vars(formula): Only the right-hand side is used.

See Also

Other bru_used: bru_used(), bru_used_update()

Examples

Run this code
bru_used_vars(~.)
bru_used_vars(~ a + b + c_latent + d_eval())
bru_used_vars(expression(a + b + c_latent + d_eval()))

bru_used_vars(~., functions = TRUE)
bru_used_vars(~ a + b + c_latent + d_eval(), functions = TRUE)
bru_used_vars(expression(a + b + c_latent + d_eval()), functions = TRUE)

bru_used_vars(a ~ b)
bru_used_vars(expression(a ~ b))

Run the code above in your browser using DataLab