Replace symbols in an expression
Arguments
- expression
Expression
- Permitted values
a quoted expression, e.g., created by
expr()
- Default value
none
- target
Target symbol
- Permitted values
an unquoted symbol, e.g.,
AVAL
- Default value
none
- replace
Replacing symbol
- Permitted values
an unquoted symbol, e.g.,
AVAL
- Default value
none
See also
Helpers for working with Quosures:
add_suffix_to_vars()
,
expr_c()
,
replace_values_by_names()
Examples
library(rlang)
replace_symbol_in_expr(expr(AVAL), target = AVAL, replace = AVAL.join)
#> AVAL.join
replace_symbol_in_expr(expr(AVALC), target = AVAL, replace = AVAL.join)
#> AVALC
replace_symbol_in_expr(expr(desc(AVAL)), target = AVAL, replace = AVAL.join)
#> desc(AVAL.join)
replace_symbol_in_expr(expr(if_else(AVAL > 0, AVAL, NA)), AVAL, AVAL.join)
#> if_else(AVAL.join > 0, AVAL.join, NA)