Learn R Programming

llmflow (version 3.0.2)

extract_function_examples: Extract Examples from a Package Function

Description

This function extracts and cleans the examples section from a specific function's documentation in an R package. It uses the `tools` package to access the Rd database and extracts examples using `tools::Rd2ex()`. The output is cleaned to remove metadata headers and formatting artifacts.

Usage

extract_function_examples(package_name, function_name)

Value

A character string containing the cleaned examples code, or `NA` if no examples are found or an error occurs

Arguments

package_name

A character string specifying the name of the package

function_name

A character string specifying the name of the function

Examples

Run this code
if (FALSE) {
# Extract examples from ggplot2's geom_point function
examples <- extract_function_examples("ggplot2", "geom_point")
cat(examples)
}

Run the code above in your browser using DataLab