almond-sh / almond

A Scala kernel for Jupyter
https://almond.sh
BSD 3-Clause "New" or "Revised" License
1.59k stars 239 forks source link

R integration? #99

Open tdhd opened 8 years ago

tdhd commented 8 years ago

Hey, I've recently discovered this project and like it quite a bit!

It would be even better if it had R integration, like python notebooks for jupyter (rmagics or rpy2) where you can prefix a line with %R and execute commands inline. Can be very useful for plotting for example, R has much better plotting capabilities when compared to matplotlib if you ask me.

Is there anything like that planned in the future or is it even wanted? I'd be willing to contribute, too.

Best, Philipp

mardukbp commented 5 years ago

You can use FastR (Oracle's implementation of R) from Almond:

  1. Download GraalVM
  2. Install FastR
  3. export JAVA_HOME=/path/to/GraalVM/Contents/Home
  4. export PATH=$JAVA_HOME/bin:$PATH
  5. Open a Jupyter Notebook running Almond and enter the following:
import org.graalvm.polyglot.Context
val context = Context.newBuilder().allowAllAccess(true).build()
context.eval("R", "print('Hello R');")

Loading FastR is slow, but afterwards it is pretty fast. It is work in progress, but ggplot is already supported. See FastR Java Interoperability and Java Interoperability in GraalVM's documentation to get started.

I think it would be a matter of developing a Scala wrapper to have nice R plotting capabilities within Almond.