find_funs: Find functions matching criteria.

View source: R/find-funs.r

find_funsR Documentation

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 documentation built on Jan. 18, 2023, 1:08 a.m.