JuliaCall provides you with functions to call Julia functions and to use Julia packages as easy as possible.
#>#>#>## Different ways for calculating `sqrt(2)` # julia$command("a = sqrt(2)"); julia$eval("a") julia_command("a = sqrt(2)"); julia_eval("a")#> 1.4142135623730951 #>#> [1] 1.414214#> [1] 1.414214#> [1] 1.414214#> [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") julia_exists("sqrt")#> [1] TRUE#> ``` #> 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`. #> #> # Examples #> #> ```jldoctest; filter = r"Stacktrace:(\n \[[0-9]+\].*)*" #> julia> sqrt(big(81)) #> 9.0 #> #> julia> sqrt(big(-81)) #> ERROR: DomainError with -8.1e+01: #> NaN result for non-NaN input. #> Stacktrace: #> [1] sqrt(::BigFloat) at ./mpfr.jl:501 #> [...] #> #> julia> sqrt(big(complex(-81))) #> 0.0 + 9.0im #> ``` #> #> ``` #> sqrt(A::AbstractMatrix) #> ``` #> #> If `A` has no negative real eigenvalues, compute the principal matrix square root of `A`, that is the unique matrix $X$ with eigenvalues having positive real part such that $X^2 = A$. Otherwise, a nonprincipal square root is returned. #> #> If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](@ref)) is used to compute the square root. Otherwise, the square root is determined by means of the Björck-Hammarling method [^BH83], which computes the complex Schur form ([`schur`](@ref)) and then the complex square root of the triangular factor. #> #> [^BH83]: Åke Björck and Sven Hammarling, "A Schur method for the square root of a matrix", Linear Algebra and its Applications, 52-53, 1983, 127-140. [doi:10.1016/0024-3795(83)80010-X](https://doi.org/10.1016/0024-3795(83)80010-X) #> #> # Examples #> #> ```jldoctest #> julia> A = [4 0; 0 4] #> 2×2 Array{Int64,2}: #> 4 0 #> 0 4 #> #> julia> sqrt(A) #> 2×2 Array{Float64,2}: #> 2.0 0.0 #> 0.0 2.0 #> ```## You can install and use Julia packages through JuliaCall # julia$install_package("Optim") julia_install_package("Optim") # julia$install_package_if_needed("Optim") julia_install_package_if_needed("Optim") # julia$installed_package("Optim") julia_installed_package("Optim")#> [1] "0.18.1"