safe_replace_var: Safely Replace Variable Names in Printed Terms

View source: R/HelperFunctions.R

safe_replace_varR Documentation

Safely Replace Variable Names in Printed Terms

Description

Replaces a variable name only when it appears as a standalone term, avoiding accidental replacements inside other words.

Usage

safe_replace_var(x, old, new)

Arguments

x

Character vector to modify.

old

Character scalar, original variable name.

new

Character scalar, replacement variable name.

Details

Useful for plot formula labels, for example replacing "t" with "that" without changing "intercept" into "inthatercept".

Value

Character vector with safe term-wise replacements.


lgspline documentation built on May 8, 2026, 5:07 p.m.