Learn R Programming

gbRd (version 0.4.12)

Rd_fun: Return all or selected sections of a help topic as an Rd object

Description

Return all or selected sections of a help topic as an Rd object. The help topic may be an Rd object, a character string (for the help function), or the value returned by the help function.

Usage

Rd_fun(x, topic, pkgname = "", help_type = "text", verbose = FALSE,
          try.all.packages = FALSE, keep_section = TRUE)

Value

an Rd object

Arguments

x

the help object. Its class may be "Rd", "character", or "help_files_with_topic".

topic

unused, see Details

pkgname

unused, see Details

help_type

type of help, see Details and help.

verbose

logical value, see help.

try.all.packages

logical value, see help.

keep_section

the section(s) to keep. If it is a character vector of length at least one, the sections listed in it (plus \title and \name) are kept in the result, the rest are dropped. Otherwise all sections are returned.

Author

Georgi N. Boshnakov

Details

If the class of x is neither "Rd" nor "help_files_with_topic", x is assumed to be appropriate for a call to help. The call is made to obtain an object of class "help_files_with_topic", which is then processed as below. Arguments help_type, verbose and try.all.packages are used only in this case.

If the class of x is "help_files_with_topic" (usually the result of a call to help), then an Rd object is obtained using tools:::fetchRdDB.

The Rd object (x itself or the one obtained as described above) is examined and sections are retained or dropped as specified by argument keep_section. Sections \title and \name are always kept in the returned value since otherwise the Rd object is considered invalid by (some of?) the system functions.

Examples

Run this code
# 1st arg is name of a function
Rd_fun("data.frame",keep_section="\\arguments")
Rd_fun("seq",keep_section="\\arguments")

# 1st arg is the value of a call to help()
h1 <- help("seq")
class(h1)
Rd_fun(h1,keep_section="\\title") # note: in Rd file the number of
Rd_fun(h1,keep_section="\\arguments") # backslashes is twice that in
                                        # the rendered doc.

Run the code above in your browser using DataLab