RGraph
Execute Graphical Functions Through R

Description

Provides for generating graphics by passing an expression to open-source R and evaluating it there.

Usage

RGraph(expr, substitute = TRUE,
    width = deviceArgs[["width"]], height = deviceArgs[["height"]],
    data = NULL, envirData = parent.frame(),
    graphicsDevice = "png", deviceArgs = list(),
    packages = getOption("RGraphPackages"),
    verbose = FALSE, display = FALSE,
    file = NULL,
    returnFilename = FALSE,
    viewer = if (graphicsDevice == "win.metafile") browseURL else getOption("viewer", default=browseURL),
    REvaluator. = RinR::REvaluator)

Arguments

expr an expression that produces the desired graphic.
substitute a logical value. If TRUE (the default), treat the expr argument as a literal expression. If FALSE, treat it as something that evaluates to the expression to pass to the remote open-source R process.
width an integer giving the width of the graphic to create. The units depend on the graphicsDevice. png and jpg use pixels while pdf and win.metafile use inches.
height an integer giving the height of the graphic to be created. The units depend on the graphicsDevice.
data if not NULL, then either a character vector or a named list specifying the objects to add into the environment where expr is evaluated. If NULL, then names in the expression, expr, that are not used as function calls are assumed to be data objects that should be sent to the plotting evaluator. Use data=character() or data=list() to cause it to not look through expr and to not send any data objects.
envirData an environment. If the data argument is a character vector naming data objects, the names are looked up in this environment.
graphicsDevice a character string specifing the R function that produces the desired graphics file format: "png", "pdf", "jpeg", or, only on Windows, "win.metafile" (Windows metafile).
deviceArgs a list with names listing the arguments to pass to the graphicsDevice. The width and height arguments are generally passed separately, but you can use them here if you use their full names.
packages a character vector identifying any packages that must be loaded before expr is evaluated.
verbose a logical value. If TRUE print some debugging information. The default is FALSE.
display a logical value. If TRUE, then the graphic is displayed using the function given as the viewer argument. In that case, the graphics file is not removed when the function is done. The default is FALSE.
file a character string naming the graphics file. If NULL (the default value), a temporary file with a file extension appropriate to the file format is used. If a file name is supplied then the file is not removed when the function finishes.
returnFilename a logical value. If FALSE (the default), returns, as a raw vector, the bytes in the file. If TRUE, returns the name of the file. In the latter case, the file is not removed when the function is done.
viewer a function that takes a name of a graphics file for an argument and displays the graphics in the file. The function browseURL works well for all supported file formats. In RStudio version 0.98.447, getOption("viewer") is a good choice, except for .wmf files.
REvaluator. an REvaluator function for a version of open-source R that can produce graphics. TIBCO Enterprise Runtime for R currently cannot produce graphics.

Details

Some functions (like those in "package:lattice" and "package:ggplot2") must be wrapped inside a print() statement to display the graphic.
This function creates an expression that is passed to REvaluate. If you want to create some graphics and return non-graphical results in one call to REvaluate you must call REvaluate directly.
RGraph uses the all.vars function, along with some heuristics, to search the expression expr for names of objects that do not look like functions. This behavior can cause some surprises. If your expr involves functions with nonstandard argument evaluation, like ~, with, or subset, RGraph may try to send objects that do not exist in the caller's environment. If your code involves a function as an argument, the function is sent to the remote R evaluator and it might not work there (for example, a built-in TIBCO Enterprise Runtime for R function such as na.omit does not work in open-source R).
Value
If returnFilename is FALSE, returns, invisibly, a raw vector containing the bytes in the graphics file. Otherwise, returns the name of the graphics file.
See Also
REvaluate
Examples
## Not run: 
library(Sdatasets)
### basic plot
RGraph(hist(fuel.frame$Disp.), data = "fuel.frame", display = TRUE)

### basic plot, sending data under a new name RGraph(hist(ff$Disp.), data=list(ff = Sdatasets::fuel.frame), display = TRUE)

### image in jpeg format, let Rgraph figure out which dataset needs to be sent grFile <- RGraph(image(voice.five), graphicsDevice="jpeg", deviceArgs=list(pointsize=20), display=TRUE, returnFile = TRUE) unlink(grFile) # clean up when done looking at the file

### use lattice package (so must use print() to make the plot). ### Since xyplot() includes data argument, RGraph does not try ### to send over the vectors named in its formula argument. RGraph(print(xyplot(Fuel ~ Weight | Type, data=fuel.frame)), packages="lattice", display = TRUE) ## End(Not run)

Package RinR version 6.0.0-69
Package Index