stefan-m-lenz / JuliaConnectoR

A functionally oriented interface for calling Julia from R
Other
100 stars 6 forks source link

Get Julia issue #13

Closed liamblything1 closed 2 years ago

liamblything1 commented 2 years ago

Hello, I'm new to this. Sounds like a great package, but I seem to be missing something...

I had used JuliaCall to run a linear mixed effect model in Julia via within the R interface. And I want to use JuliaConnectoR to transfer that model object into an R object.

My syntax for running the model is here (runs well):

j$assign("MODELNAME", Response ~ (predictor1) (predictor2) (predictor3) * + (1 | participant) + (1 | item)) j$eval("@elapsed MODELNAME = fit(LinearMixedModel, MODELNAME, Data)") # Fit the model in Julia (and time it)

Then I hoped that translating the model into an R object would be as simple as this: library(JuliaConnectoR) juliaGet(MODELNAME)

However, I get the following error:

ERROR: SystemError: opening file "C:\Users\lpb_1\OneDrive": Permission denied Stacktrace: [1] systemerror(p::String, errno::Int32; extrainfo::Nothing) @ Base .\error.jl:168 [2] #systemerror#62 @ .\error.jl:167 [inlined] [3] systemerror @ .\error.jl:167 [inlined] [4] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Nothing, append::Nothing) @ Base .\iostream.jl:293 [5] open @ .\iostream.jl:282 [inlined] [6] open(f::Base.var"#326#327"{String}, args::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ Base .\io.jl:328 [7] open @ .\io.jl:328 [inlined] [8] read @ .\io.jl:434 [inlined] [9] _include(mapexpr::Function, mod::Module, _path::String) @ Base .\loading.jl:1166 [10] include(mod::Module, _path::String) @ Base .\Base.jl:386 [11] exec_options(opts::Base.JLOptions) @ Base .\client.jl:285 [12] _start() @ Base .\client.jl:485 Error in testJSON(julia_bin) : Unable to continue: failed to get JSON. Try Pkg.add() from julia directly

Any ideas? Really want this to work so that I can do some simr power checks in R!

Liam

stefan-m-lenz commented 2 years ago

The model you have has not been created by the JuliaConnectoR. It is not possible to translate it with the JuliaConnectoR. If you want to apply juliaGet, you need to apply it to a reference that has been created via the JuliaConnectoR. But also then, in this case you probaby get a complex Julia object that can't be translated simply. You need to extract the information from the model with customized code.

liamblything1 commented 2 years ago

Ah okay thank you so much for your help, Stefan!