Examples for 'XML::XMLCodeFile-class'


Simple classes for identifying an XML document containing R code

Aliases: XMLCodeFile-class XMLCodeDoc-class xmlCodeFile [[,XMLCodeFile-method [[,XMLCodeFile,ANY-method coerce,XMLCodeFile,XMLCodeDoc-method coerce,character,XMLCodeDoc-method coerce,character,XMLCodeFile-method source,XMLCodeFile-method

Keywords: classes

### ** 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)
*************
Evaluating node
expression(myFun = 
function(n)
{
  sum(sample(1:10, n, replace = TRUE))
})
*************
Evaluating node
expression(inRect <-
function(pos, x, y, w, h)
{
  pos[1] >= x & pos[2] >= y &   pos[1] <= x + w & pos[2] <= y + h
})
*************
Evaluating node
expression(inRect(c(10, 10), 3, 4, 10, 10), myFun())
   # read and evaluate the code in a special environment.
 e = new.env()
 ans = xmlSource(k, envir = e)
*************
Evaluating node
expression(myFun = 
function(n)
{
  sum(sample(1:10, n, replace = TRUE))
})
*************
Evaluating node
expression(inRect <-
function(pos, x, y, w, h)
{
  pos[1] >= x & pos[2] >= y &   pos[1] <= x + w & pos[2] <= y + h
})
*************
Evaluating node
expression(inRect(c(10, 10), 3, 4, 10, 10), myFun())
 ls(e)
[1] "inRect" "myFun" 

[Package XML version 3.99-0.10 Index]