Seamless Integration Between R and 'Julia'

Provides an R interface to 'Julia', which is a high-level, high-performance dynamic programming language for numerical computing, see < https://julialang.org/> for more information. It provides a high-level interface as well as a low-level interface. Using the high level interface, you could call any 'Julia' function just like any R function with automatic type conversion. Using the low level interface, you could deal with C-level SEXP directly while enjoying the convenience of using a high-level programming language like 'Julia'.


Travis-CI Build Status AppVeyor Build Status CRAN_Status_Badge

Table of Contents

Package JuliaCall is an R interface to 'Julia', which is a high-level, high-performance dynamic programming language for numerical computing, see https://julialang.org/ for more information. Below is an image for Mandelbrot set. JuliaCall brings more than 100 times speedup of the calculation! See https://github.com/Non-Contradiction/JuliaCall/tree/master/example/mandelbrot for more information.

Installation

JuliaCall is on CRAN now! To use package JuliaCall, you first have to install Julia https://julialang.org/ on your computer, and then you can install JuliaCall just like any other R packages by

install.packages("JuliaCall")

You can get the development version of JuliaCall by

devtools::install_github("Non-Contradiction/JuliaCall")

Basic Usage

library(JuliaCall)
 
julia <- julia_setup()
#> Julia at location /Applications/Julia-0.6.app/Contents/Resources/julia/bin will be used.
#> Julia version 0.6.1 found.
#> Julia initiation...
#> Finish Julia initiation.
#> Loading setup script for JuliaCall...
#> Finish loading setup script for JuliaCall.
 
## Different ways for using Julia to calculate sqrt(2)
 
# julia$command("a = sqrt(2);"); julia$eval("a")
julia_command("a = sqrt(2);"); julia_eval("a")
#> [1] 1.414214
julia_eval("sqrt(2)")
#> [1] 1.414214
julia_call("sqrt", 2)
#> [1] 1.414214
julia_eval("sqrt")(2)
#> [1] 1.414214
julia_assign("x", sqrt(2)); julia_eval("x")
#> [1] 1.414214
julia_assign("rsqrt", sqrt); julia_call("rsqrt", 2)
#> [1] 1.414214
2 %>J% sqrt
#> [1] 1.414214
 
## You can use `julia$exists` as `exists` in R to test
## whether a function or name exists in Julia or not
 
julia_exists("sqrt")
#> [1] TRUE
julia_exists("c")
#> [1] FALSE
 
## You can use `julia$help` to get help for Julia functions
 
julia_help("sqrt")
#> ```
#> sqrt(x)
#> ```
#> 
#> Return $\sqrt{x}$. Throws [`DomainError`](@ref) for negative [`Real`](@ref) arguments. Use complex negative arguments instead. The prefix operator `√` is equivalent to `sqrt`.
 
## Functions related to installing and using Julia packages
 
julia_install_package("Optim")
julia_install_package_if_needed("Optim")
julia_installed_package("Optim")
#> [1] "0.10.1"
julia_library("Optim")

How to Get Help?

  • One way to get help for julia functions is just using julia$help like the following example:
julia_help("sqrt")
#> ```
#> sqrt(x)
#> ```
#> 
#> Return $\sqrt{x}$. Throws [`DomainError`](@ref) for negative [`Real`](@ref) arguments. Use complex negative arguments instead. The prefix operator `√` is equivalent to `sqrt`.

JuliaCall for R Package Developers

If you are interested in developing an R package which is an interface for a Julia package, JuliaCall is an ideal choice for that!

Basically you only need to find the Julia function or Julia module you want to have in R and then just using the module and call the function. An example is ipoptjlr, which can be found at https://github.com/Non-Contradiction/ipoptjlr.

If you have any issues in developing an R package using JuliaCall, you may report it using the link: https://github.com/Non-Contradiction/JuliaCall/issues/new. Or email me at [email protected] or [email protected].

Suggestion and Issue Reporting

JuliaCall is under active development now. Any suggestion or issue reporting is welcome! You may report it using the link: https://github.com/Non-Contradiction/JuliaCall/issues/new. Or email me at [email protected] or [email protected].

And if you encounter some issues which crash R or RStudio, then you may have met segfault errors. I am very sorry. And I am trying my best to remove errors like that. It will be much appreciated if you can

  • download the source of JuliaCall from Github,
  • open JuliaCall.Rproj in your RStudio or open R from the directory where you download the source of JuliaCall,
  • run devtools::check() to see the result of R CMD check for JuliaCall on your machine,
  • and paste the result to the issue report.

News

JuliaCall 0.7.3

  • First release on CRAN.
  • julia_setup for initial setup of JuliaCall.
  • julia_eval_string, julia_command for executing commands in julia.
  • julia_do.call and julia_call for calling functions in julia.
  • Functions to deal with julia packages.
  • Helper functions like julia_help.

JuliaCall 0.7.4.9000

  • Added a NEWS.md file to track changes to the package.
  • Add helpful error messages in libjulia DLL load and compilation.
  • Add julia_assign which can assign a value to a name in julia with automatic type conversion.
  • Give the option to set path for julia.
  • Deprecate julia_check.
  • julia_console. Now there is a fully functional julia repl in R terminal, and a usable julia console when you use IDE for R.
  • In julia_setup, there is an option whether or not to use RCall.jl, RCall's R REPL mode and rgui will be set correctly.

JuliaCall 0.7.5.9000

  • Have a basic julia display system, now the plot functionality in Julia works (mostly).
  • JuliaCall is more consistent with julia.

JuliaCall 0.8.0.9000

  • julia.do_call and julia_call now accept keyword arguments.
  • JuliaCall works in Jupyter R notebook.
  • JuliaCall works in R Markdown. The display system currently only work for html document. When there is no return from julia function and there is a need to display, a div with class=‘JuliaDisplay’ will be inserted into the html document with the corresponding content.
  • Julia engine in R Markdown through JuliaCall.

JuliaCall 0.9.0.9000

  • Try to convert julia tuple.
  • Add JuliaObject, which serves as a proxy in R for julia object, which is the automatic conversion target when other choices are not possible.
  • julia_setup() doesn't need to be called first unless you want to force julia to restart or you need to set the julia path.

JuliaCall 0.9.1.9000

  • Improve JuliaObject, same Julia object could enter julia_object_dict only once. And the display of JuliaObject becomes better. Also every common types of Julia Object could be wrapped by JuliaObject.
  • The users could now choose to have JuliaObject type return value instead of R Object.
  • Dot notation in julia is now accepted through the julia_call interface.
  • julia_eval_string is deprecated in favor of julia_eval.

JuliaCall 0.9.2.9000

  • New Julia display system plotsViewer(), which integrates better into R.
  • Fits several bugs in JuliaCall, like removing using of depreated function.
  • Improve display systems of RMarkdown and Jupyter R Notebook.

JuliaCall 0.9.3

  • Second release on CRAN.

JuliaCall 0.9.3.9000

  • Performance improvements for dot notation function call.

JuliaCall 0.10.0.9000

  • Implementation of JuliaArray.

JuliaCall 0.10.1.9000

  • Bug fix in JuliaArray.
  • Do not convert Tuple any more.

JuliaCall 0.10.2.9000

  • Important bug fix in JuliaObject, for more detail, see github issue #15, issue #12 and #13 are related.

JuliaCall 0.10.3.9000

  • Dispatching for JuliaObject and JuliaArray.

JuliaCall 0.10.4.9000

  • Do not use JuliaArray, the discussion is in #16.
  • JuliaObject is an S4 class now, which should be more robust.

JuliaCall 0.10.5.9000

  • Implement generics for JuliaObject, and fix many small bugs.
  • Fix the bug of the conversion of AbstractArray{Any}.
  • Julia tuple converts to R S3 class of JuliaTuple based on list.
  • Add fields, field and field<- function for JuliaObjects.

JuliaCall 0.10.6.9000

  • Use R6 for the implementation of JuliaObject. It's lightweight, faster, and safer.

JuliaCall 0.11.0.9000

  • Remove deprecated julia_eval_string.
  • Improve JuliaCall RMarkdown engine. The display system should work for all kinds of documents that rmarkdown supports.
  • Should use older version of RCall with older version of R.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("JuliaCall")

0.14.0 by Changcheng Li, 13 days ago


https://github.com/Non-Contradiction/JuliaCall


Report a bug at https://github.com/Non-Contradiction/JuliaCall/issues


Browse source code at https://github.com/cran/JuliaCall


Authors: Changcheng Li [aut, cre], Randy Lai [ctb], Dmitri Grominski [ctb], Nagi Teramo [ctb]


Documentation:   PDF Manual  


Task views: Numerical Mathematics


MIT + file LICENSE license


Imports utils, R6, Rcpp

Suggests testthat, knitr, rmarkdown

Linking to Rcpp

System requirements: Julia >= 0.6.0, RCall.jl


Imported by convexjlr, diffeqr.

Suggested by knitr.


See at CRAN