# RCall UndefVarError

**URL:** <https://discourse.julialang.org/t/rcall-undefvarerror/101027>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 30, 2023, 5:25pm UTC](https://discourse.julialang.org/t/rcall-undefvarerror/101027 "2023-06-30T17:25:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eweiss](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@eweiss](https://discourse.julialang.org/u/eweiss)\
**Post date:** [June 30, 2023, 5:25pm UTC](https://discourse.julialang.org/t/rcall-undefvarerror/101027/1 "2023-06-30T17:25:23Z")

</div>

I’m running the REPL with this code:

using RCall  
function demo()  
@rlibrary tidyquant  
R"tidyquant::tq\_index(‘DOW’)"  
end

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  
Stacktrace:  
[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?

---

<div class="post-metadata">

**Author:** ![palday](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palday/32/12640_2.png) [@palday](https://discourse.julialang.org/u/palday)\
**Post date:** [June 30, 2023, 7:34pm UTC](https://discourse.julialang.org/t/rcall-undefvarerror/101027/2 "2023-06-30T19:34:51Z")

</div>

What happens when you run

```julia
using RCal
@rlibrary tidyquant
R"tidyquant::tq_index(‘DOW’)"

```

WIthout the function cal wrapper?

---

<div class="post-metadata">

**Author:** ![eweiss](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@eweiss](https://discourse.julialang.org/u/eweiss)\
**Post date:** [July 1, 2023, 1:37am UTC](https://discourse.julialang.org/t/rcall-undefvarerror/101027/3 "2023-07-01T01:37:49Z")

</div>

There’s a different problem…

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

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [July 1, 2023, 11:03am UTC](https://discourse.julialang.org/t/rcall-undefvarerror/101027/4 "2023-07-01T11:03:17Z")

</div>

There could be an error in your R code?

---

<div class="post-metadata">

**Author:** ![eweiss](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@eweiss](https://discourse.julialang.org/u/eweiss)\
**Post date:** [July 1, 2023, 9:29pm UTC](https://discourse.julialang.org/t/rcall-undefvarerror/101027/5 "2023-07-01T21:29:53Z")

</div>

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

works.

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