body_insert: Insert Into a Function Body

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Insert quoted insertions at the start of a function body (after the opening of the function).

Usage

1
body_insert(fn_body, insertion, before = NULL)

Arguments

fn_body

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

insertion

A quoted expression to add at the beginning of the function.

Value

A function body with the insertion. Note: If before is specified and is not found anywhere in fn_body, fn_body is returned unaltered.

Examples

1
2
3
4
fun <- function(x) {
  x + 1
}
body_insert(body(fun), quote(x + 2))

jonthegeek/factory documentation built on June 4, 2020, 1:41 p.m.