Interface between Octave and R

Hi there

Does anyone know if there is active development for a package that would allow Octave users to harness the power of R, a dedicated statistical programming environment. Specifically, I mean to call R functions from octave and use the output as variables in octave. Perhaps it can already be achieved by by generating system calls but that seems a bit clunky. I noticed this package but it looks oooold (ROctave package). If I understand it correctly, RcppOctave interface is in the opposite direction. That would be useful too although I’m not sure how active the development is there either.



1 Like

There is no ready-made package that I know of. I last looked into this in mid 2019 so the situation may have changed. Back then a colleague of mine who was an R expert would send me R snippets as evidence for her recommendations, and I would try to cross-check with Octave, since I’m much more comfortable with Octave than with R. I looked for some way to run R code from within Octave other than calling system() but there wasn’t much that could be used out of the box.

By all means, if you have such a link please publish it.

Out of genuine curiosity, is there any problem that one of those languages can do that the other cannot? Most of my colleagues’ work in R is with regression models, which could be done with Octave too, but if there are things that would require significant effort in reinventing the wheel then by all means outsourcing that sort of computation to the other language makes a lot of sense.

Jupyter/lab notebooks support using Octave and R interchangeably. However, it will be very useful to natively call R and Python from Octave.

Thanks @arungiridhar, I became an R (RStudio) user last year by necessity because the statistics module (for life scientists) I taught on is based on R. It has it’s merits, there is a huge developer base contributing a lot of great solutions to statistical problems. I was blown away when I started using it and now routinely use a range of packages like lme4, BayesFactors, emmeans and brms. Matlab has some similar functions that can more or less do some of the same jobs, such as fitlm and fitlme. Unfortunately Octave doesn’t have these solutions (yet) although I think it should be feasible. Not sure though I have time myself to code it right now. Like you said about reinventing the wheel, I pondered whether Octave can interface with R.

I didn’t know that about Jupyter/lab notebooks @adityaapte! (I confess I’ve only dabbled with Jupyter but I’ll give it a go!)

Not sure if it wins points with developers here but the first coding I ever dabbled with seriously was Octave back in 2008 :star_struck:

Fyi, SymPy is linked from Octave’s symbolic package. (pkg load symbolic)

General Python isn’t but if you want to you can look at the symbolic package to see how they call Python.