appendToBody: Append values to function body

Description Usage Arguments Value Note See Also Examples

View source: R/appendToBody.R

Description

Append values to function body

Usage

1
appendToBody(fun, values, after = 1L)

Arguments

fun

function.

values

call. Quoted values (i.e. call) to slot in the function body.

after

integer(1). Where to append in the body. The default of 1L places directly after the opening curly bracket.

Value

function.

Note

Updated 2019-08-23.

See Also

Stack Overflow

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Add a deprecation call into function body.
fun <- function() { print("hello world") }
body(fun)

## values: call ====
values <- as.call(quote(.Deprecated("XXX")))
x <- appendToBody(fun = fun, values = values)
body(x)

## values: list ====
values <- list(
    quote(print("AAA")),
    quote(print("BBB"))
)
x <- appendToBody(fun = fun, values = values)
body(x)

acidgenomics/AcidBase documentation built on Sept. 10, 2021, 1:27 a.m.