Martin Kavalar / Oct 23 2018

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.

wget --progress=bar:force -O /results/graalvm-ce-linux-amd64.tar.gz https://github.com/oracle/graal/releases/download/vm-1.0.0-rc8/graalvm-ce-1.0.0-rc8-linux-amd64.tar.gz
graalvm-ce-linux-amd64.tar.gz
tar xvzf graalvm-ce-linux-amd64.tar.gz -C /usr/local
java -version

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.

R --help --no-save

We link the graalpython executable so it's availble as just python.

ln -s /usr/local/graalvm-ce-1.0.0-rc8/bin/graalpython /usr/local/graalvm-ce-1.0.0-rc8/bin/python

Let's test that python works:

python --version:graalvm

The nextjournal runtime requires base64enc, jsonlite and devtools to be installed.

R -e 'install.packages(c("base64enc", "jsonlite", "feather", "devtools"))'

2.
Using fastR

Let's try running GraalVM's R by creating an R code cell that uses the GraalVM environment created above:

And, we're running fastR! 🎉

c(1, 2, 3)