jl-helpers-utils | R Documentation |
Helpers for converting model specifications in R to Julia equivalents
is_jl(x, type)
jl_put(x)
jl_get(x)
jl(expr, ..., .R = FALSE, .passthrough = FALSE)
jl_dict(...)
x |
An object |
type |
Type of Julia object to additional test for |
expr |
A string of Julia code |
... |
Interpolated elements. In the case of
|
.R |
Whether to simplify and return as R object, if possible. |
.passthrough |
Whether to return |
A Julia object of type <JuliaProxy>
# (general) Use `jl()` to evaluate arbitrary Julia expressions from string
jl("1 .+ [1,3]")
# `jl()` takes elements in `...` that you can reference in the expression
jl("1 .+ a", a = c(1L, 3L)) # Named arguments are introduced as variables
jl("1 .+ %s", "[1,2]") # Unnamed arguments are interpolated via `sprintf()`
# Use `is_jl()` to test if object is a Julia (`<JuliaProxy>`) object
is_jl(jl("1"))
# Use `jl_put()` and `jl_get()` to transfer data between R and Julia
jl_put(1L)
identical(jl_get(jl_put(1L)), 1L)
# `jl_dict()` opinionatedly constructs a Dictionary data type
## Basic `list()`-like usage
jl_dict(age = 20:25, sex = c("M", "F"))
## Splats when a single list is supplied
jl_dict(list(a = 1, b = 2))
## Wrap scalars in `I()` to prevent vector conversion
jl_dict(a = 1:2, b = 3:4, c = I(5))
stop_julia()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.