Learn R Programming

statuser (version 0.1.9)

validate_formula: Validate Formula Variables

Description

Checks if the input is a formula and validates that all variables mentioned in the formula exist either in the provided data frame or in the environment. This is a lightweight validation function that should be called early in functions that accept formula syntax.

Usage

validate_formula(
  formula,
  data = NULL,
  func_name = "function",
  calling_env = parent.frame()
)

Value

Returns NULL invisibly. Stops with an error if validation fails.

Arguments

formula

A potential formula object to validate (can be any object).

data

An optional data frame containing the variables.

func_name

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

calling_env

The environment in which to look for variables if data is not provided. Defaults to parent.frame().