Skip to contents

This function extracts the body of a function as a single character.

Usage

function_body(fun, braces = FALSE, nchar = getOption("width") - 4)

Arguments

fun

[function]
A function.

braces

[logical(1)]
Remove "{" and "}" at start and end (if any)?

nchar

[integer(1)]
The maximum number of characters before abbreviation, at least 3.

Value

A character, the body of f.

See also

Examples

fun <- mean.default
function_body(fun)
#> [1] "if (!is.numeric(x) && !is.complex(x) && !is.logical(x)) { warning(\"argume..."
function_body(fun, braces = TRUE)
#> [1] "{ if (!is.numeric(x) && !is.complex(x) && !is.logical(x)) { warning(\"argu..."
function_body(fun, nchar = 30)
#> [1] "if (!is.numeric(x) && !is.c..."