getPackageRefs | R Documentation |
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.
getPackageRefs(doc, asNodes = FALSE, ...)
getOptionRefs(doc, asNodes = FALSE, ...)
getFunctionRefs(ar, doc = ar[[getDocument(ar)]])
getClassRefs(doc, asNodes = FALSE, ...)
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. |
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.
Duncan Temple Lang duncan@wald.ucdavis.edu
wordDoc
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.