| frm_find_and_replace | R Documentation |
This function traverses a language object (such as an expression or call) and recursively replaces all occurrences of a specified symbol with another symbol.
frm_find_and_replace(expr, find_sym, replace_sym)
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 |
replace_sym |
A symbol (as a name) to replace |
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).
The modified language object with all instances of find_sym replaced by replace_sym.
## Not run:
expr <- quote(a + b * c)
frm_find_and_replace(expr, as.name("b"), as.name("x"))
# Returns: a + x * c
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.