find_funs: Find functions matching criteria.

Description Usage Arguments Examples

View source: R/find-funs.r

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

1
2
3
4
5
6
7
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

1
2
3
4
5
6
7
8
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 Feb. 18, 2018, 9:02 a.m.