juliaLet | R Documentation |
let
block using values of R variablesR variables can be passed as named arguments, which are inserted
for those variables in the Julia expression that have the same name
as the named arguments. The given Julia code is executed in Julia
inside a let
block and the result is translated back to R.
juliaLet(expr, ...)
expr |
Julia code, given as one-element character vector |
... |
arguments that will be introduced as variables in the
|
A simple, nonsensical example for explaining the principle:
juliaLet('println(x)', x = 1)
This is the same as
juliaEval('let x = 1.0; println(x) end')
More complex objects cannot be simply represented in a string like in
this simple example any more.
That is the problem that juliaLet
solves.
Note that the evaluation is done in a let
block. Therefore,
changes to global variables in the Julia session are only possible by
using the keyword global
in front of the Julia variables
(see examples).
The value returned from Julia, translated to an R data structure.
If Julia returns nothing
, an invisible NULL
is returned.
if (juliaSetupOk()) {
# Intended use: Create a complex Julia object
# using Julia syntax and data from the R workspace
juliaLet('[1 => x, 17 => y]', x = rnorm(1), y = rnorm(2))
# Assign a global variable
# (although not recommended for a functional style)
juliaLet("global x = xval", xval = rnorm(10))
juliaEval("x")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.