"R" (External Evaluation System)
- 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["R",code] executes the code string in R and returns the result as a Wolfram Language expression.
- The following R built-in types are supported:
|logical||True | False||Boolean True/False values|
|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|
|data frame||RDataFrame||RLink data type|
- All calls to R run in a single R session, whether they are executed via ExternalEvaluate or via an ExternalLanguage cell.
- The R session used is the same one used by RLink, so you can interleave calls using RLink functions with calls using ExternalEvaluate.
Examplesopen allclose all
Basic 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:
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: