Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

find_funs

Find functions matching criteria.


Description

This is a flexible function that matches function component against a regular expression, returning the name of the function if there are any matches. fun_args and fun_calls are helper functions that make it possible to search for functions with specified argument names, or which call certain functions.

Usage

find_funs(env = parent.frame(), extract, pattern, ...)

fun_calls(f)

fun_args(f)

fun_body(f)

Arguments

env

environment in which to search for functions

extract

component of function to extract. Should be a function that takes a function as input as returns a character vector as output, like fun_calls or fun_args.

pattern

stringr regular expression to results of extract function.

...

other arguments passed on to grepl

f

function to extract information from

Examples

find_funs("package:base", fun_calls, "match.fun", fixed = TRUE)
find_funs("package:stats", fun_args, "^[A-Z]+$")

fun_calls(match.call)
fun_calls(write.csv)

fun_body(write.csv)
find_funs("package:utils", fun_body, "write", fixed = TRUE)

pryr

Tools for Computing on the Language

v0.1.4
GPL-2
Authors
Hadley Wickham [aut, cre], R Core team [ctb] (Some code extracted from base R)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.