CodeDepends (version 0.6.6)

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, ...)

Value

an object of class DynScript

Arguments

doc

the name/location of the document containing the R code

...

any additional arguments, passed to readScript.

Author

Duncan Temple Lang

Details

This uses a reference class to update state across calls.

See Also

readScript

Examples

Run this code
fil <- file.path(tempdir(), "foo.R")
cat("x = 1:10\ny = 3*x + 7 + rnorm(length(x))\n",  file = fil)
sc = updatingScript(fil)

as(sc, "Script")

con = file(fil, "at")
cat("z = x + y", file = con)
close(con)

as(sc, "Script")

Run the code above in your browser using DataLab