"R" (External Evaluation System)
Details
- R is a language and environment for statistical computing and graphics.
- ExternalEvaluate with R works via RLink, and no further configuration is needed if RLink is functioning.
ExternalEvaluate Usage
- ExternalEvaluate["R",code] executes the code string in R and returns the result as a Wolfram Language expression.
Data Types
- The following R built-in types are supported:
-
logical True False Boolean True/False values integer Integer integer double Real real number complex Complex complex number character String string of characters array List list of objects vector List list of objects with the same data type list List list of objects of different types matrix List multidimensional list data frame RDataFrame RLink data type NA Missing missing value
Usage Notes
- All calls to R run in a single R session, whether they are executed via ExternalEvaluate or via an external language cell.
- The R session used is the same one used by RLink, so you can interleave calls using RLink functions with calls using ExternalEvaluate.
Examples
open allclose allBasic Examples (3)
When scalars are entered, they are automatically considered vectors of length 1 by R:
R lists are returned as Wolfram Language lists:
Type > and select R from the drop-down menu to get a code cell that uses ExternalEvaluate to evaluate:
Scope (5)
Evaluate a Boolean expression:
In R, numbers are of type double by default:
You can force a number to be an integer by appending L:
R objects are returned as RLink RObject expressions:
R functions are returned as RLink RFunction expressions:
You can mix calls to the same R session using ExternalEvaluate and RLink functions: