Closed woodwards closed 6 years ago
I think I am having a problem because an old session of Julia is stuck and I don't know how to reset it.
> library(XRJulia)
> findJulia() # finds Julia
[1] "C:\\Users\\WoodwardS\\AppData\\Local\\JuliaPro-0.6.2.1\\Julia-0.6.2\\bin\\julia.exe"
> findJulia(test=TRUE) # checks that Julia exists
[1] TRUE
> juliaAddToPath(getwd()) # tell Julia to looks for modules here
> juliaUsing("combin")
Error in assign(.actionMetaName(anames[[i]]), actions[[i]], envir = where) :
cannot add bindings to a locked environment
Restarting R does not fix it.
It's a bug in juliaAddToPath() (and some other function-level shortcuts).
The workaround is to use the methods of the evaluator directly. So, for example, this works to call a function foo() exported from a module "temp" in the working directory:
ev <- RJulia() ev$AddToPath(getwd()) ev$Using("temp") ev$Call("foo", 1)
(I'll come back to this thread when I get a chance to fix the bugs)
Thank you, that's excellent, i got that working!
By the way I am running the example at
https://insightr.wordpress.com/2017/10/18/writing-julia-functions-in-r-with-examples/
A somewhat cleaner way of proceeding in that example (not importing everything via "using") and that also saves some typing is to form the proxies for the Julia functions explicitly.
In my previous example:
ev$AddToPath(getwd()) foo <- JuliaFunction("foo", module = "temp") foo(1)
The problems with juliaAddToPath() and juliaImport()/juliaUsing() should now be solved. You need to install both XR and XRJulia from the revised versions as of March 2 on github.
Is there any way to stop/clear Julia remotely using XRJulia?
Thanks