The rscala package provides a bridge between R and Scala, enabling a user to exploit each language's respective strengths in a single project. The rscala package brings Scala and Java libraries into R with a simple interface. 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 and callbacks to R are supported. Conversely, rscala also enables arbitrary R code to be embedded within a Scala application.
In R, install the package by executing:
install.packages("remotes")
remotes::install_github("dbdahl/rscala/R/rscala")
To install --- or check the compatability of your existing installation of --- Scala and Java, please execute:
rscala::scalaConfig()
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" % "3.2.19"
Or if you're managing dependencies with Maven, you may add the following to
your pom.xml
file, replacing the version numbers for Scala and for this
library as appropriate.
<dependency>
<groupId>org.ddahl</groupId>
<artifactId>rscala_2.13</artifactId>
<version>3.2.19</version>
</dependency>
The original paper describing the software is:
D. B. Dahl (2020), Integration of R and Scala using rscala, Journal of Statistical Software, 92:4, 1-18, doi:10.18637/jss.v092.i04.
The citation information is available using:
citation("rscala")
An updated version of the paper is available here.
vignette("rscala")
The functionality of the software is also described and demonstrated in the help files:
library(help="rscala")
library(rscala)
example(scala)
R extensions can be written using this package, as demonstrated by these packages:
- Vignette describing the package usage.
- Git repository containing source code and build & test scripts.
- Scaladoc for RClient class to access R from Scala.