EVOLUTION-MANAGER
Edit File: Rsource.xml
<?xml version="1.0"?> <article xmlns:r='http://www.r-project.org'> <para> This is a very simple example of using an XML file to create annotated R code that defines some functions and also has a "main" script in the style of Python scripts that can be loaded or run. <r:function id="myFun"> myFun = function(n) { sum(sample(1:10, n, replace = TRUE)) } </r:function> </para> <para> We define a second function and we use an id attribute "B" eventhough this is not the name of the function. Note also that we use the CDATA construct to specify the content of the node as the code contains characters < and > and & that are special to XML. <r:function id="B"> <![CDATA[ inRect <- function(pos, x, y, w, h) { pos[1] >= x & pos[2] >= y & pos[1] <= x + w & pos[2] <= y + h } ]]> </r:function> We only need to surround this code with the start and end of the CDATA delimeters and we don't have to escape the individual characters. This makes it easier to cut and paste the code directly into another application. </para> <para> <r:code> inRect(c(10, 10), 3, 4, 10, 10) myFun() </r:code> </para> </article>