Learn R Programming

statuser (version 0.1.9)

evaluate_variable_arguments: Evaluate Variable Arguments with NSE Support

Description

Resolves bare symbols (unquoted names) or quoted strings to actual data, either from a data frame or the calling environment. This enables both plot_density(DV1, data=df) and plot_density("DV1", data=df) to work identically.

Usage

evaluate_variable_arguments(
  arg_expr,
  arg_name = "arg",
  data = NULL,
  calling_env = parent.frame(),
  func_name = "function",
  allow_null = FALSE
)

Value

A list with:

  • value: The actual data (vector, formula, or NULL)

  • name: Clean name for labels (e.g., "DV1")

  • name_raw: Raw name for error messages (e.g., "df$DV1")

  • was_symbol: Logical. TRUE if input was an unquoted name

Arguments

arg_expr

Unevaluated expression (from match.call() or substitute())

arg_name

Character string. Name of the argument (for error messages)

data

Optional data frame to look up columns

calling_env

Environment to evaluate symbols if data is NULL

func_name

Character string. Name of calling function (for error messages)

allow_null

Logical. If TRUE, NULL is a valid input. Default FALSE.