RCall UndefVarError

I’m running the REPL with this code:

using RCall
function demo()
@rlibrary tidyquant

And I get the error message:

Warning: RCall.jl: Registered S3 method overwritten by ‘quantmod’:
│ method from
│ as.zoo.data.frame zoo
└ @ RCall ~/.julia/packages/RCall/LWzAQ/src/io.jl:172
ERROR: UndefVarError: ##RCall#292 not defined
[1] eval
@ ./boot.jl:370 [inlined]
[2] macro expansion
@ ~/.julia/packages/RCall/LWzAQ/src/namespaces.jl:96 [inlined]
[3] demo()
@ Main ./REPL[2]:2
[4] top-level scope
@ REPL[3]:1

Any suggestions on how to get this to work?

What happens when you run

using RCal
@rlibrary tidyquant

WIthout the function cal wrapper?

1 Like

There’s a different problem…

julia> R"tidyquant::tq_index(‘DOW’)"
ERROR: LoadError: RParseError: Error: unexpected input
in expression starting at REPL[60]:1

There could be an error in your R code?

For the record, the problem seems to be you can’t include the @rlibrary macro within a Julia function. Since R allows you to specify a package with the :: notation, or you can use it outside the Julia function, it’s not a big deal.

Alternatively, a single line like

dj = rcopy(R"tidyquant::tq_index(‘DOW’)")


palday, thanks for the suggestion that got me going in the right direction.