Learn R Programming

statuser (version 0.1.9)

validate_plot: Validate Inputs for Plotting Functions

Description

Validates inputs for plotting functions that accept either formula syntax (y ~ group) or standard syntax (y, group), with optional data frame.

Usage

validate_plot(
  y,
  group = NULL,
  data = NULL,
  func_name = "plot",
  require_group = TRUE,
  data_name = NULL
)

Value

A list containing:

  • y: Validated y variable (numeric vector)

  • group: Validated group variable (if provided, otherwise NULL)

  • y_name: Clean variable name for y (for labels)

  • group_name: Clean variable name for group (for labels)

  • y_name_raw: Raw variable name for y (for error messages)

  • group_name_raw: Raw variable name for group (for error messages)

  • data_name: Name of data argument (for error messages)

Arguments

y

A numeric vector, column name, or formula of the form y ~ group.

group

A vector used to group the data, or a column name if data is provided. Can be NULL for functions where group is optional.

data

An optional data frame containing the variables.

func_name

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

require_group

Logical. If TRUE, group is required. If FALSE, group can be NULL.

data_name

Character string. Name of the data argument (for error messages). If NULL, will attempt to infer from the call.