Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using RCall produces warning message #36

Closed
ericmelse opened this issue May 7, 2024 · 5 comments
Closed

Using RCall produces warning message #36

ericmelse opened this issue May 7, 2024 · 5 comments

Comments

@ericmelse
Copy link

Dear Ebad,
Thank you for all your work on rcall.
I am reading your TSJ paper and try to replicate your examples with, so far, limited success.
I have R installed, version 4.3.2 and Stata version 18.5 (StataNow/MP).
When I run this code:

clear all
cd "C:/ado/R" // required
rcall setpath "C:/Program Files/R/R432/bin/R.exe"
rcall: setwd("C:/ado/R") // required
rcall: print("Hello world")

what is returned is:

. rcall: print("Hello world")
[1] "Hello world"
Warning message:
 In  :  

which means that the two programs do work together.
But, I cannot explain the Warning message: as such.
Can you explain what is the problem and how to resolve it?
Best regards,
Eric

@haghish
Copy link
Owner

haghish commented Jul 15, 2024

Why are you setting your working directory to "C:/ado/R"? it is likely that this directory is restricted. rcall needs to create files in your local directory to communicate between the two software. If the directory is restricted, naturally, the communication would be broken. Try using a directory where you and your Stata have full access to read and write file in that location. Working in "C:/ado/R" is really not recommended...

@haghish haghish closed this as completed Jul 15, 2024
@ericmelse
Copy link
Author

Dear Ebad,
Thank you for giving me your advice. I have now used a most simple folder straight under the root: C:/Rcall
Neither R:

> setwd("C:/Rcall")
> getwd()
[1] "C:/Rcall"

nor Stata has an issue with it:

. cd "C:/Rcall" // required
C:\Rcall
. pwd
C:\Rcall

So, I would think that issue is solved but running this code from Stata (v.18):

rcall clear
rcall setpath "C:/Program Files/R441/bin/R.exe"
rcall: setwd("C:/Rcall")
rcall: print("Hello world")

Produces twice a warning message, like:

. rcall clear
(R memory cleared)

. rcall setpath "C:/Program Files/R441/bin/R.exe"

. rcall: setwd("C:/Rcall")
Warning message:
 In  :  

. rcall: print("Hello world")
[1] "Hello world"
Warning message:
 In  :  

To compare, using this code in Stata:

rcall clear             //clear the R interactive session
rcall setpath "C:/Program Files/R441/bin/R.exe"
rcall: str <- "Hello World"
display r(str)

Also produces that warning message, like:

. rcall clear             //clear the R interactive session
(R memory cleared)

. rcall setpath "C:/Program Files/R441/bin/R.exe"

. rcall: str <- "Hello World"
Warning message:
 In  :  

. display r(str)
Hello World

Although R producs the Hello World text string, I find the warning message disturbing. Maybe you know why this might be happening and how to solve it.

@haghish
Copy link
Owner

haghish commented Jul 16, 2024

I think I fixed the bug. Strange that this issue surfaced now! I updated the developmental version (not a stable release). So just reinstall rcall with github package

@haghish
Copy link
Owner

haghish commented Jul 16, 2024

So now I understand why this bug surfaced after years. R has changed of warnings() function as of version 4.4.0, which made the older code of rcall generate this output. Now it is fixed. thank you

@ericmelse
Copy link
Author

Indeed, I now can run the examples mentioned above without the warning. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants