listPackageFunctions: Extract Functions and Descriptions from an R Package

View source: R/listPackageFunctions.R

listPackageFunctionsR Documentation

Extract Functions and Descriptions from an R Package

Description

This function extracts the list of functions contained within a specified R package and retrieves a brief description for each function from the package documentation. The description is obtained by parsing the Rd file associated with each function to extract the text from the \title field. In addition, the function determines whether each function is exported from the package by comparing against the package’s exported names.

Usage

listPackageFunctions(pkg)

Arguments

pkg

A character string or an unquoted name specifying the package from which to extract functions. The package must be installed and accessible.

Details

The function first accesses the package namespace using asNamespace and retrieves all objects using ls. It filters these objects to include only functions. For each function, the associated help file is retrieved using utils::help and the Rd file is extracted with utils:::.getHelpFile. The internal helper function getRdTitle is then used to parse the Rd object and extract the text in the \title field. Finally, the function assembles the output into a data frame that also includes an indicator of whether each function is exported.

Value

A data frame with three columns. The Function column lists the names of the functions found in the package. The Description column contains the brief descriptions extracted from each function’s documentation, and the Exported column is a logical vector indicating whether the function is exported from the package.

Examples

## Not run: 
# Extract functions from the stats package along with their descriptions and export status.
tab <- listPackageFunctions("stats")
print(tab)

## End(Not run)


ices-tools-dev/icesRDBES documentation built on April 17, 2025, 1:58 p.m.