Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling R functions from Julia

Tags:

julia

Is there a convenient way to call R functions from Julia?

If so, what mechanisms for doing so exist? (Potentially ranging from simply calling an R script from the shell & hand-coding the I/O to/from Julia, to interacting with an R environment over multiple Julia calls with Julia DataFrames being seamlessly converted to/from R DataFrames).

like image 500
Ben Hamner Avatar asked Jan 12 '23 01:01

Ben Hamner


2 Answers

Calling R scripts and handcoding I/O is the best way to work with R for the moment. We have functions for reading the RDA binary format that R likes and should add some tools for working with it more easily and also writing data in that format, which will speed up I/O considerably relative to passing CSV files around -- which I've done in the past.

Converting between R and Julia DataFrames could be done, but would be quite costly as Julia isn't using a binary representation of data (e.g. NA) that's nearly equivalent to R's. So you'd need to do some non-trivial work to make this work in a way that would be substantially more efficient than using the RDA binary format.

One thing that would be really nice is to build solid Thrift bindings for both R and Julia and then call back and forth using those bindings.

like image 127
John Myles White Avatar answered Jan 13 '23 14:01

John Myles White


For calling out to R from within Julia, the RCall package is currently your best bet. For calling out to Julia from within R, try the RJulia package. Both are a bit in the works.

like image 25
Adam Erickson Avatar answered Jan 13 '23 15:01

Adam Erickson