Go + R + Go + Emacs = Rbooks

118 views
Skip to first unread message

Jason E. Aten

unread,
Mar 28, 2024, 5:27:40 AM3/28/24
to golang-nuts
https://github.com/glycerine/rbook

I've open sourced my rbook project. I built rbook for myself to save data
analysis in R to a file which serves as a lab notebook. I call the 
program rbook, and the saved files rbooks.  

I regularly use emacs and ESS (Emacs-Speaks-
Statistics) for R based data analysis, and I wanted a way
to record the sequence of plots and R output to a web browser.

With rbooks, I can easily revisit and scroll through the analysis.
All R commands and output or recorded, plots are shown 
in-line, and comments can be inserted.  R can run out of 
memory and crash, so it is nice to be able to have a persistent
session log--with graphics--to recovery and start again from.

Using rbook is similar to Jupyter Notebooks and Jupyter Hub, but
this is a completely independent project. I prefer emacs and ESS to Jupyter,
as it is much faster to work in. I have ctrl-n bound to step through
code, making debugging R code seamless.  From my .emacs:

(global-set-key "\C-n" 'ess-eval-line-and-step)

The rbook project also demonstrates that it is viable to have a Go program
host DLLs that are also written in Go. By controlling the signal
handling, the two Go runtimes can coexist.

Rbook is a Go program uses my R embedding library ( https://github.com/glycerine/embedr ) to load R as a DLL. 

In turn, R can load other Go code that has been built to be an R package DLL.

The embedr and rbook Go code does the signal handling settings
needed to make this possible.  This took a long time to figure out,
but it has been stable and working for a year now.

I find it incredibly useful to be able to call into my Go code from R.

Enjoy.

Reply all
Reply to author
Forward
0 new messages