makeREvaluator
Make a Function That Evaluates an Expression in an R-language Interpreter
Description
Make a function that evaluates an expression in an R-language intepreter.
Usage
makeREvaluator(RProgName, RHome = NULL, RBinDir = NULL,
startFlags = NULL, envVars = NULL,
interpreterType = sub("[^[:alpha:]].*$", "", toupper(basename(RProgName))),
arch = NULL)
configureREvaluator(evaluator, FullPath, startFlags = NULL, envVars = NULL,
arch = NULL, nonUNCDir)
## S3 method for class 'REvaluator':
print(x, complete = FALSE, ...)
Arguments
RProgName |
a character string giving the name of the R interpreter.
|
RHome |
a character string giving the home directory of the R interpreter.
|
startFlags |
a character string giving command line arguments to the R interpreter.
These are appended to the default command line arguments
" --quiet --vanilla --no-echo".
|
envVars |
a named vector of character strings specifying the names and values of
environment variables to set before spawning the R interpreter. A value
of NA_character_ specifies unsetting the variable.
|
RBinDir |
a character string giving the bin directory of the R interpreter.
If not given and RHome is known,
then it is set to be the "bin" subdirectory of RHome.
|
interpreterType |
either "R" or "TERR" (case matters),
saying whether the interpreter is a version of open-source R
or of TIBCO Enterprise Runtime for R. If not given, it is determined from the
first few characters in RProgName.
|
arch |
a character string (or NULL) used only for R interpreters on Windows to tell
whether you want a 32- or 64-bit intepreter. "32" (or "i386")
means 32-bit and "64" (or "x64") means 64-bit.
NULL, the default, means to use the same architecture as the
currently running intepreter. "" means to not ask for any particular
architecture (which currently means to use the 32-bit R interpreter).
|
x |
the "REvaluator" object to print.
|
complete |
a logical value. If TRUE, print just the arguments to the function. If FALSE
(the default), print the entire function.
|
... |
other arguments to print for REvaluator objects are silently ignored.
|
evaluator |
the REvaluator object to configure. It should be an object created by makeREvaluator.
|
FullPath |
a string specifying the full file path to the open-source R or TIBCO Enterprise Runtime for R executable. The default values
come from options("RinR_R_FULL_PATH") or options("RinR_TERR_FULL_PATH"), if they
are set. See Note for more details.
|
nonUNCDir |
a string giving the full name of a directory, in the "diskLetter:/..." format, not the UNC "//machine/..." format,
that will be used on Windows to launch the cmd.exe subprocess from.
No files will be accessed in this directory and the R or TERR subprocess will revert to the directory used
by the calling process before running the requested expressions;
Windows cmd.exe needs to start in a directory whose name starts with a letter then a colon.
If it is the empty string the subprocess will be launched from the current directory.
The default value on Windows is the first of tempdir(), Sys.getenv("TMP"), Sys.getenv("TEMP"),
and Sys.getenv("windir") that starts with a letter and a colon.
On Linux the default value is the empty string.
|
Value
returns a function that starts an R interpreter
in a new process, evaluates the expression there,
and gets the result when the interpreter is done.
See
REvaluator for a description of the function.
Note
The REvaluator functions store important values in their associated environments.
(These values include the full file path of the executable to be called, along with the
arguments to the function. Also, if you used the envVars argument when you made
or configured the object to set environment variables, the result of that is stored as well.
This is useful information if you examine the default evaluators, REvaluator and
TERREvaluator, because it conveys the results of the autoconfiguration.)
These values are not printed by the default print method.
To display these values, call the appropriate REvaluator function's print method.
configureREvaluator is called from the .onLoad function for the RinR package,
unless you set options(RinR_DONT_CONFIGURE=TRUE). In that case, or if the full
paths to the open-source R and TIBCO Enterprise Runtime for R executables cannot be found, the default evaluators assume
that executables called "R" and "TERR" are in a directory in Sys.getenv("PATH").
- If configureREvaluator cannot find the full file path to the open-source R or TIBCO Enterprise Runtime for R
executables from the default values specified in options("RinR_R_FULL_PATH") or
options("RinR_TERR_FULL_PATH"), configureREvaluator searches the Windows registry
and commonly-used places in the file system to find where open-source R and TIBCO Enterprise Runtime for R are installed.
- If that search is not successful, configureREvaluator uses a path based on the value of R.home()
when configuring the evaluator whose type matches the type of currently running program.
- If all else fails, RinR uses "R" for the standard REvaluator and "TERR" for the standard
TERREvaluator. Its success depends on whether you reconfigured or used pushPATH
to ensure executables by those names are on the system PATH before you use the evaluators.
configureREvaluator modifies the evaluator; it returns nothing useful.
See Also
Examples
## Not run:
R2.15.1 <- makeREvaluator("R", RHome="C:/Program Files/R/R-2.15.1")
REvaluate(version, REvaluator=R2.15.1)
R3.0.1 <- makeREvaluator("R-3.0.1", envVars=c(R_LIBS_SITE="/tmp"))
R3.0.1
REvaluate(.libPaths(), REvaluator=R3.0.1)
configureREvaluator(REvaluator, FullPath="C:/Program Files/R/R-3.0.1/bin/R")
REvaluator
## End(Not run)