Search code examples
rstata

Glitch in R-Stata communication


I am attempting to use the community-contributed command rcall in Stata.

I wish to begin by bringing vectors and/or variables from Stata to R. My vector X is also a matrix X. When I use the code below to send R my variable X:

rcall: Y = st.var(X)

I get the following error:

too many numeric literals

If instead I use the code below, to send R my matrix X:

rcall: Y = st.matrix(X)

I get the error below:

Y not found

Though occasionally I'm pretty sure I've gotten the numeric literals error for this matrix attempt.

In addition, in neither case does it help if I replace = with <-.

I have a feeling I'm using this command quite wrong, but I am following the Stata help code. So far, I have been unable to find any further examples of rcall online.

Any help would be appreciated!

Note that this question has been cross-posted (a few days ago, with no reply) on Statalist.


Solution

  • Problems like these usually result either from something not installed correctly, or the software in question starts encountering memory leaks and becomes unstable because of continuous usage.

    After installing rcall, the following works for me:

    matrix A = (1,2\3,4)
    
    rcall: Y <- st.matrix(A) 
    rcall: Y
    
       c1 c2
    r1  1  2
    r2  3  4
    

    So assuming rcall is correctly installed, then the R session that it uses may have been corrupted.

    Try typing from Stata's command prompt:

    rcall clear
    

    This will erase the R session's memory and history.