julia_pkg_wrap {JuliaCall} | R Documentation |
Wrap julia functions and packages the easy way.
Description
Wrap julia functions and packages the easy way.
Usage
julia_function(func_name, pkg_name = "Main", env = new.env(emptyenv()))
julia_pkg_import(pkg_name, func_list, env = new.env(parent = emptyenv()))
julia_pkg_hook(env, hook)
Arguments
func_name |
the julia function name to be wrapped. |
pkg_name |
the julia package name to be wrapped. |
env |
the environment where the functions and packages are wrapped. |
func_list |
the list of julia function names to be wrapped. |
hook |
the function to be executed before the execution of wrapped functions. |
Examples
if (identical(Sys.getenv("AUTO_JULIA_INSTALL"), "true")) { ## julia_setup is quite time consuming
## do initialization and automatic installation of Julia if necessary
julia_setup(installJulia = TRUE)
julia_install_package_if_needed("Optim")
opt <- julia_pkg_import("Optim",
func_list = c("optimize", "BFGS"))
rosenbrock <- function(x) (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
result <- opt$optimize(rosenbrock, rep(0,2), opt$BFGS())
result
}
[Package JuliaCall version 0.17.5 Index]