search_function: Search functions in a package matching a pattern.

Description Usage Arguments Details Value See Also Examples

View source: R/serach_functions.R

Description

You may need a function which name you remember only partly. Use this function to serach all functions which name match whatever you remember.

Usage

1

Arguments

pattern

Argument passed to base::grepl().

pkg_nm

A character string giving the name of the package to search.

Details

There are multiple ways to find a function in a package, e.g. with the autocomplete feature in RStudio; by searching the package's index; and by searching the function's reference in the package's website. However, there is no way to do it programmatically. This function provides a programmatic way to search functions in a package, based on a user-defined pattern, and makes it easy to search multiple patterns at once via lapply().

Value

A vector of characters

See Also

base::grepl()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# R loads a number of packages automatically. See what those packages are:
search()

# Directly search functions in any package already loaded: e.g. "base"
search_function("summary", pkg_nm = "base")

# Case is ignored
search_function("Summary", pkg_nm = "base")

# Easily search multiple patterns with lapply
multiple_patterns <- c("min", "ply")
lapply(multiple_patterns, search_function, pkg_nm = "base")

# If the package you want to search isn't load it, you must load it first.
## Not run: 
library(ggplot2)
search_function("point", pkg_nm = "ggplot2")

## End(Not run)

maurolepore/handy documentation built on May 21, 2019, 1:37 p.m.