getClassRefs: Extract references to R functions, classes, packages etc....

View source: R/msWord.R

getPackageRefsR Documentation

Extract references to R functions, classes, packages etc. from a Word document

Description

These functions allow the caller to find marked-up content in a Word document that refers R-related concepts such as functions, classes, packages and options. We can use these to ensure they are spelled correctly, identify actual R objects, see if they need to be renamed to match changes in code, or to programmatically generate, for example, bibliographies.

These functions allow one to either get the content, i.e. the text, in the document, or alternatively the XML nodes containing the content. We can use the latter approach to then programmatically update the underlying XML document and hence the .docx file.

Usage

getPackageRefs(doc, asNodes = FALSE, ...)
getOptionRefs(doc, asNodes = FALSE, ...)
getFunctionRefs(ar, doc = ar[[getDocument(ar)]])
getClassRefs(doc, asNodes = FALSE, ...)

Arguments

doc

the WordArchive object representing the .docx file, or the parsed XML document corresponding to the main document in the Word archive.

asNodes

a logical value

...

additional parameters passed on to

ar

the WordArchive object representing the .docx file.

Value

If asNodes is TRUE, then a list of XMLInternalElementNode objects is returned. Otherwise, the functions return a character vector giving the content, but

getFunctionRefs returns a frequency table, with the table names being the function names.

Author(s)

Duncan Temple Lang duncan@wald.ucdavis.edu

See Also

wordDoc

Examples

   #  This illustrates these functions on a document that discusses this 
 #  RWordXML package.
f = system.file("SampleDocs", "RWordDocTools.docx", package = "RWordXML")
doc = wordDoc(f)
getPackageRefs(doc)
getClassRefs(doc)
getFunctionRefs(doc)
getOptionRefs(doc)
        

duncantl/RWordXML documentation built on Nov. 23, 2023, 4:23 p.m.