Skip to contents

Parse the documentation for a function and save the working examples to an R script. Note that the f argument is parameterized and can handle multiple requests in a single call.

Usage

saveRdExamples(rd = NULL, package, dir = getwd())

Arguments

rd

character or NULL. R documentation name(s) from which to parse and save the working examples. If NULL, all documentation files containing examples will be saved.

package

character(1). Package name.

dir

character(1). Directory path.

Value

Invisible character. File path(s).

Note

Updated 2022-05-31.

Examples

dir <- file.path(tempdir(), "testdata")
out <- saveRdExamples(
    rd = c("do.call", "droplevels"),
    package = "base",
    dir = dir
)
#> Saved 2 Rd examples from base to '/private/var/folders/l1/8y8sjzmn15v49jgrqglghcfr0000gn/T/RtmpoGTXL6/testdata'.
print(out)
#>                                                                                     do.call 
#>    "/private/var/folders/l1/8y8sjzmn15v49jgrqglghcfr0000gn/T/RtmpoGTXL6/testdata/do.call.R" 
#>                                                                                  droplevels 
#> "/private/var/folders/l1/8y8sjzmn15v49jgrqglghcfr0000gn/T/RtmpoGTXL6/testdata/droplevels.R" 
unlink(dir, recursive = TRUE)