GraalVM
Nextjournal's default R environment provides an up-to-date release of the language along with a collection of common packages to get you started quickly and easily. However, it is conceivable that you might want to use another version of R like Oracle's Java implementation called FastR.
This example demonstrates the flexibility transclusions afford the user. A FastR environment is built in this article and can transcluded as an R environment in another. For performance's sake, the author also installs an extension to the Java Virtual Machine called GraalVM. All of these implementation details can be ignored in all articles that use this environment, allowing the researcher to focus on their work
1. Installation
We start by downloading graal VM community edition from GitHub.
tar xvzf graalvm-ce-1.0.0-rc7-linux-amd64.tar.gz↩ -C /usr/local
ln -s /usr/local/graalvm-ce-1.0.0-rc7/bin/java /usr/bin/java java -version
ln -s /usr/local/graalvm-ce-1.0.0-rc7/bin/gu /usr/bin/gu
OpenMP and GCC are required to run fastR.
apt-get update apt-get install -y libomp-dev gcc make
gu available
Let's install python and R.
gu install org.graalvm.python gu install org.graalvm.R
Let's confirm we can use R.
ln -s /usr/local/graalvm-ce-1.0.0-rc7/jre/languages/R/bin/R /usr/bin/R
R --help --no-save
We link the graalpython
executable so it's availble as just python
.
ls /usr/local/graalvm-ce-1.0.0-rc7/jre/languages/python/bin/graalpython
ln -s /usr/local/graalvm-ce-1.0.0-rc7/jre/languages/python/bin/graalpython /usr/bin/python
Let's test that python works:
python --version:graalvm
The nextjournal runtime requires jsonlite to be installed.
apt-get install libcurl4-openssl-dev zlib1g-dev libssl-dev -y
R -e 'install.packages(c("base64enc", "jsonlite", "feather", "devtools", "tidyverse", "plotly", "svglite"))'
R -e 'devtools::install_github("hadley/ggplot2")'
2. Using fastR
Let's try running GraalVM's R by creating an R code cell that uses the GraalVM environment created above:
c(1, 2, 3)
And, we're running fastR! 🎉