demoSource {SoDA}R Documentation

Flexible execution of R source for demonstrations

Description

R expressions in a source file are shown and evaluated sequentially, using a simple prompt (in a separate R session). Additional R expressions can be inserted at any point in the demonstration.

Usage

demoSource(demo, inputCon,  where = .GlobalEnv)
demoInput(path=)

demoExample(name, package = "SoDA")

Arguments

demo Either the file name or input connection for the R source to be demonstrated, or an object from class "demoSource". The latter allows resuming a demo.
inputCon The connection from which to read prompt input. Usually omitted in which case a call to demoInput() should occur in another R session in the same directory (see the details).
where The environment where the demo expressions should be evaluated. By default, in the global environment.
path The file system path where user input is passed to the demo controller. Must be a writable location and be known to both R sessions. Usually omitted, in which case a suitable fifo is created to communicate with demoSource().
name For demoExample(), the name of the example file, with or without a ".R" suffix. There should be a corresponding file in the "Examples" subdirectory of the package.
package The name of the package to use to find the example file.

Details

Calling demoSource starts up a controller that reads input from the input connection. This is normally a file opened in the directory where both R sessions are running. In the control session, the user calls demoInput, which then goes into a loop reading terminal input and writing to the file.

In the demo R session, the user then calls demoSource, usually just supplying the file name for the source file. The controller now reads from a fifo connected to the file and interprets the lines as follows. Empty lines (the usual) alternately display and evaluate single lines from the source file. A line consisting only of a comma is a continuation: The next line of the source is read and displayed but not yet evaluated. Use this mechanism to collect a bunch of lines to be evaluated together, such as a function definition. When the last line of the bunch is displayed, enter an empty line to evaluate all the lines at once.

Any other input is interpreted as a literal expression that the user wants evaluated instead of the next source line.

Value

demoSource() and demoExample() return, invisibly, the "demoSource" object describing the current state of the demo.

See Also

demoSource-class()

Examples






[Package SoDA version 0.97-1 Index]