RCall.jl
RCall.jl copied to clipboard
Use RCall from Julia modules
Hello, RCall.jl is such a great package that I use it everyday. Thank you all the contributors so much for the great work. I encountered the issue when using RCall.jl from Julia modules. I want to wrap ggplot2 functions in Julia function called plotr
inside Julia module named SomeModule
. I want to call this module for my research project, which is another module. I follow best practices from Modules · The Julia Language
This is my src/SomeModule.jl
module SomeModule
using RCall
export plotr
@rlibrary ggplot2
include("plot.jl")
end
This is src/plot.jl
function plotr()
ggplot() + geom_density(aes(rand(10), rand(10)))
end
In REPL using SomeModule
errors with (I truncated irrelevant hash)
julia> using SomeModule
[ Info: Precompiling SomeModule [.................]
ERROR: LoadError: Evaluation into the closed module `__anonymous__`
breaks incremental compilation because the side effects will not be permanent.
This is likely due to some other module mutating `__anonymous__` with `eval` during
precompilation - don't do this.
in expression starting at /home/milan/SomeModule/src/SomeModule.jl:1
ERROR: Failed to precompile SomeModule [.................] to /home/milan/.julia/compiled/v1.6/SomeModule/jl_ydAA1Z.
Stacktrace:
[1] compilecache(pkg::Base.PkgId, path::String, internal_stderr::Base.T
TY, internal_stdout::Base.TTY)
@ Base ./loading.jl:1360
How do I resolve the issue?
I have the same issue. Did you find any workarounds?
it seems that one workaround (depeding on your use case) is to simply put require(copula)
at the beginning fo the r snippet like this:
R"require(copula);
set.seed(19470101);
myCop <- copula::tCopula(param=$julia_corrvec, dim = $ncolumns, dispstr = $dispstrString, df = $degreesOfFreedom, df.fixed = TRUE);"