The Scala interpreter is embedded in R and callbacks to R from the embedded interpreter are supported. Conversely, the R interpreter is embedded in Scala.

rscala: Bi-Directional Interface Between R and Scala with Callbacks

By David B. Dahl, Brigham Young University

The rscala package provides a two-way bridge between R and Scala enabling a user to exploit each language's respective strengths in a single project. The rscala package transparently brings Scala and Java methods into R as if they were native R functions. Specifically, Scala classes can be instantiated and methods of Scala classes can be called directly. Furthermore, arbitrary Scala code can be executed on the fly from within R, inline Scala functions can be defined, and callbacks to the original R interpreter are supported. Finally, rscala also enables arbitrary R code to be embedded within a Scala application. The rscala package is available on CRAN and requires no special installations or configurations of R or Scala.

Install the package in R by executing:


Note that if only want to embed R in a Scala application, you don't need to install the package. Simply add the following line to the your SBT build.sbt file:

libraryDependencies += "org.ddahl" %% "rscala" % "1.0.15"