body_replace: Replace Parts of a Function Body

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Replace quoted targets in the body of a function with quoted replacements.

Usage

1
body_replace(fn_body, target, replacement)

Arguments

fn_body

The body of a function (as found via body(fun)).

target

A quoted expression to replace.

replacement

A quoted expression with which the target should be replaced.

Value

A function body with the target replaced anywhere it occurs.

Examples

1
2
3
4
fun <- function(x) {
  x^exp
}
body_replace(body(fun), quote(exp), quote(!!exp))

factory documentation built on Aug. 21, 2019, 9:05 a.m.