Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RCall from Julia modules #429

Closed
milan-kasprowicz opened this issue Aug 15, 2021 · 2 comments
Closed

Use RCall from Julia modules #429

milan-kasprowicz opened this issue Aug 15, 2021 · 2 comments

Comments

@milan-kasprowicz
Copy link

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?

@kafisatz
Copy link

I have the same issue. Did you find any workarounds?

@kafisatz
Copy link

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);"

@palday palday closed this as completed Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants