RCall.jl icon indicating copy to clipboard operation
RCall.jl copied to clipboard

Error: attempt to apply non-function

Open schlichtanders opened this issue 2 years ago • 4 comments

For some julia values, the call method is not supported on R side

PlutoUI = julia_eval("using PlutoUI; PlutoUI")
PlutoUI$Slider(c(1,2,3))

returns

REvalError: Error: attempt to apply non-function

    var"#handle_eval_stderr#31"(::Bool, ::typeof(RCall.handle_eval_stderr))@io.jl:174
    [email protected]:168[inlined]
    reval_p(::Ptr{LangSxp}, ::Ptr{EnvSxp})@eval.jl:103
    reval_p(::Ptr{RCall.ExprSxp}, ::Ptr{EnvSxp})@eval.jl:119
    reval(::String, ::RObject{EnvSxp})@eval.jl:136
    reval(::String)@eval.jl:136
    macro expansion@[Local: 299](...)[inlined]
    top-level scope@[Local: 1](...)[inlined]

It would be great if the R call syntax works also here to run the julia call.

Workaround

julia_call("PlutoUI.Slider", c(1,2,3))

schlichtanders avatar Oct 29 '23 17:10 schlichtanders

Another example:

HTML <- julia_eval("HTML")
HTML("<h1> title </h1>")

gives an error

could not find function "HTML"

despite it is callable on julia side

schlichtanders avatar Nov 02 '23 13:11 schlichtanders

@simonbyrne can you comment here?

schlichtanders avatar Nov 13 '23 08:11 schlichtanders

This feels like a JuliaCall issue and not an RCall issue even if the error didn't happen until it hit RCall -- I suspect something in JuliaCall's wrapping and passing isn't complete.

palday avatar Nov 14 '23 02:11 palday

I opened an issue at JuliaCall https://github.com/Non-Contradiction/JuliaCall/issues/215

schlichtanders avatar Nov 14 '23 09:11 schlichtanders

Closing this for now, but if it turns out that there is actually something we can do on the RCall side to make things easier for JuliaCall, then I'm happy to revisit.

palday avatar Jul 17 '24 11:07 palday