frm_find_and_replace: Recursively find and replace symbols in a language object
Description
This function traverses a language object (such as an expression or call)
and recursively replaces all occurrences of a specified symbol with another symbol.
Usage
frm_find_and_replace(expr, find_sym, replace_sym)
Value
The modified language object with all instances of find_sym replaced by replace_sym.
Arguments
expr
A language object (e.g., call, expression, or list of calls) to search and modify.
find_sym
A symbol (as a name) to find within expr.
replace_sym
A symbol (as a name) to replace find_sym with.
Details
Replacement happens for symbols found within calls (recursively). A expr that is
itself a bare symbol equal to find_sym is returned unchanged; this is not reachable
from the ancova() call site because the input is always a formula (a call).