Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

XMLCodeFile-class

Simple classes for identifying an XML document containing R code


Description

These two classes allow the user to identify an XML document or file as containing R code (amongst other content). Objects of either of these classes can then be passed to source to read the code into R and also used in link{xmlSource} to read just parts of it. XMLCodeFile represents the file by its name; XMLCodeDoc parses the contents of the file when the R object is created. Therefore, an XMLCodeDoc is a snapshot of the contents at a moment in time while an XMLCodeFile object re-reads the file each time and so reflects any "asynchronous" changes.

Objects from the Class

One can create these objects using coercion methods, e.g as("file/name", "XMLCodeFile") or as("file/name", "XMLCodeDoc"). One can also use xmlCodeFile.

Slots

.Data:

Object of class "character"

Extends

Class "character", from data part. Class "vector", by class "character", distance 2.

Methods

[[

signature(x = "XMLCodeFile", i = "ANY", j = "ANY"): this method allows one to retrieve/access an individual R code element in the XML document. This is typically done by specifying the value of the XML element's "id" attribute.

coerce

signature(from = "XMLCodeFile", to = "XMLCodeDoc"): parse the XML document from the "file" and treat the result as a XMLCodeDoc object.

source

signature(file = "XMLCodeFile"): read and evaluate all the R code in the XML document. For more control, use xmlSource.

Author(s)

Duncan Temple Lang

See Also

Examples

src =  system.file("exampleData", "Rsource.xml", package = "XML")
   # mark the string as an XML file containing R code
 k = xmlCodeFile(src)

   # read and parse the code, but don't evaluate it.
 code = xmlSource(k, eval = FALSE)

   # read and evaluate the code in a special environment.
 e = new.env()
 ans = xmlSource(k, envir = e)
 ls(e)

XML

Tools for Parsing and Generating XML Within R and S-Plus

v3.99-0.10
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2013), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>), Tomas Kalibera [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.