I want to run an R script through Stata. I can successfully *open* the script in Rstudio, via Stata, this way:
I see that others execute R scripts via something like:
Additionally, I am aware of the Rsource package, but I think this is more capability than I need. I don't want to run the R code within Stata, or import R objects into Stata after running. I merely want Stata to tell terminal "Run this particular R script," and then wait for the run to complete before continuing on with the Stata code. So I *think* shell is the right avenue, if I can get it to work.
Would appreciate mac-specific advice! Thanks so much. Cross-posted on Stack Overflow.
shell open -a RStudio "PATHWAY/filename.R"And in terminal, I can successfully *run* the script through the command:
Rscript "PATHWAY/filename.R"However, shell Rscript "PATHWAY/filename.R" returns the error /bin/bash: Rscript: command not found.
I see that others execute R scripts via something like:
shell "C:\Program Files\R\R-2.15.1\bin\x64\R.exe" CMD BATCH test.RHowever, I am unsure about the equivalent R command pathway on a Mac. (Or why I need a pathway at all, since I can execute the file in terminal w/ the mere command Rscript, and can open the file w/ shell in Stata, without a pathway.) Following notes here, I find that file.path(R.home("bin"), "R") returns "/Library/Frameworks/R.framework/Resources/bin/R", but adding this path way to the command (shell /Library/Frameworks/R.framework/Resources/bin/R/R.exe "PATHWAY/filename.R") doesn't help.
Additionally, I am aware of the Rsource package, but I think this is more capability than I need. I don't want to run the R code within Stata, or import R objects into Stata after running. I merely want Stata to tell terminal "Run this particular R script," and then wait for the run to complete before continuing on with the Stata code. So I *think* shell is the right avenue, if I can get it to work.
Would appreciate mac-specific advice! Thanks so much. Cross-posted on Stack Overflow.
Comment