CodeDepends (version 0.5-3)

updatingScript: Create a Script object that re-reads the original file as needed

Description

This function reads the code in a particular document and creates a Script-class object to represent the code and allow us to do analysis on that code. Unlike readScript, this object continues to read any updates to the original code file when we use this Script object in computations. This allows us to modify the original source interactively and concurrently with our R session and still have the script remain up-to-date with that code.

Usage

updatingScript(doc, ...)

Arguments

doc

the name/location of the document containing the R code

any additional arguments, passed to readScript.

Value

an object of class DynScript

Details

This uses a reference class to update state across calls.

See Also

readScript

Examples

Run this code
# NOT RUN {
cat("x = 1:10\ny = 3*x + 7 + rnorm(length(x))\n",  file = "foo.R")
sc = updatingScript("foo.R")

as(sc, "Script")

con = file("foo.R", "at")
cat("z = x + y", file = con)
close(con)

as(sc, "Script")
# }

Run the code above in your browser using DataCamp Workspace