JuliaSwitch
is a high-level R
–Julia
interface. The package
provides a common syntax that enables users to switch between multiple
backends for R
–Julia
communication without changes to the code base.
- Run
Julia
code via ajulia_*()
helper function orjulia_cmd_line()
/julia_cmd_block()
; - Push objects to
Julia
usingjulia_push()
; - Pull objects back via
julia_pull()
;
JuliaSwitch
was motivated our work on animal tracking with patter
.
This package provides an R
interface to Patter.jl
, which fit
state-space models to animal-tracking data in Julia
.
When
patter
was first developed, we usedJuliaCall
as aR
–Julia
interface. That package connectsR
andJulia
via aC
interface, which is fast but can be unstable acrossJulia
versions and platforms. (We experienced particular challenges on Linux when usingR
andJulia
packages that require the same dynamic libraries.)
JuliaConnectoR
is anotherR
–Julia
option. UnlikeJuliaCall
, this package interfacesR
andJulia
using Transmission Control Protocol. This is a looser form of integration which trades speed for stability.
JuliaSwitch
became the solution to toggle between these two options.
JuliaSwitch
can be installed with:
install.packages("devtools")
devtools::install_github("edwardlavender/JuliaSwitch",
dependencies = TRUE)
-
Run
julia_backend("JuliaCall")
orjulia_backend("JuliaConnectoR")
to set theJulia
backend. -
Start a
Julia
session viajulia_start()
. -
Run arbitrary
Julia
code viajulia_cmd_line()
andjulia_cmd_block()
. -
For selected operations, helper functions are provided:
julia_pkg_activate()
activates a local environment;julia_pkg_add()
adds packages;julia_using()
andjulia_import()
load and import packages;julia_include()
sourcesJulia
scripts;julia_println()
prints lines;julia_save()
andjulia_load()
save and load files;
-
To push objects from
R
toJulia
, usejulia_push()
. -
To pull objects back from
Julia
toR
, usejulia_pull()
. -
Stop a
Julia
session viajulia_stop()
.
JuliaSwitch
uses S3
methods to handle object transfers between R
and Julia
. Method dispatch is implemented by the internal functions
julia_allot()
, juliaAllot()
and juliaTranslate()
.The default
methods call the relevant JuliaCall
or JuliaConnectoR
routines.
Special cases (such as data.frame
s and terra::SpatRaster
s) are
handled by custom methods. Specify additional methods for other special
cases.
Please note that the JuliaSwitch
project is released with a
Contributor Code of
Conduct.
By contributing to this project, you agree to abide by its terms.