Learn R Programming

tools (version 3.5.2)

RdTextFilter: Select Text in an Rd File

Description

This function blanks out all non-text in an Rd file, for spell checking or other uses.

Usage

RdTextFilter(ifile, encoding = "unknown", keepSpacing = TRUE,
             drop = character(), keep = character(),
             macros = file.path(R.home("share"), "Rd", "macros", "system.Rd"))

Arguments

ifile

An input file specified as a filename or connection, or an "Rd" object from parse_Rd.

encoding

An encoding name to pass to parse_Rd.

keepSpacing

Whether to try to leave the text in the same lines and columns as in the original file.

drop

Additional sections of the Rd to drop.

keep

Sections of the Rd file to keep.

macros

Macro definitions to assume when parsing. See parse_Rd.

Value

A character vector which if written to a file, one element per line, would duplicate the text elements of the original Rd file.

Details

This function parses the Rd file, then walks through it, element by element. Items with tag "TEXT" are kept in the same position as they appeared in the original file, while other parts of the file are replaced with blanks, so a spell checker such as aspell can check only the text and report the position in the original file. (If keepSpacing is FALSE, blank filling will not occur, and text will not be output in its original location.)

By default, the tags \S3method, \S4method, \command, \docType, \email, \encoding, \file, \keyword, \link, \linkS4class, \method, \pkg, and \var are skipped. Additional tags can be skipped by listing them in the drop argument; listing tags in the keep argument will stop them from being skipped. It is also possible to keep any of the c("RCODE", "COMMENT", "VERB") tags, which correspond to R-like code, comments, and verbatim text respectively, or to drop "TEXT".

See Also

aspell, for which this is an acceptable filter.