Dear Statlist members,
I would like to run a file written in R program from a Stata do file. I would appreciate if somebody helps me how to invoke R from Stata. Many thanks! Ljubica Ljubica Nedelkoska PhD student Research group: "Economics of Innovative Change" Friedrich Schiller Universität-Jena +49(0)3641 (9) 43 272 ---------------------------------------------------------------- This mail was sent through http://webmail.uni-jena.de * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
Line for the server... *********** ssc d rsource *********** HTH Martin -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Ljubica Nedelkoska Sent: Monday, December 01, 2008 4:38 PM To: [hidden email] Subject: st: Invoking R from Stata Dear Statlist members, I would like to run a file written in R program from a Stata do file. I would appreciate if somebody helps me how to invoke R from Stata. Many thanks! Ljubica Ljubica Nedelkoska PhD student Research group: "Economics of Innovative Change" Friedrich Schiller Universität-Jena +49(0)3641 (9) 43 272 ---------------------------------------------------------------- This mail was sent through http://webmail.uni-jena.de * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
In reply to this post by Ljubica Nedelkoska
Line for the server...
Also note http://www.stata.com/meeting/4german/shikano_StataMeeting2006.pdf HTH Martin -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Ljubica Nedelkoska Sent: Monday, December 01, 2008 4:38 PM To: [hidden email] Subject: st: Invoking R from Stata Dear Statlist members, I would like to run a file written in R program from a Stata do file. I would appreciate if somebody helps me how to invoke R from Stata. Many thanks! Ljubica Ljubica Nedelkoska PhD student Research group: "Economics of Innovative Change" Friedrich Schiller Universität-Jena +49(0)3641 (9) 43 272 ---------------------------------------------------------------- This mail was sent through http://webmail.uni-jena.de * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
In reply to this post by Ljubica Nedelkoska
Run from stata:
! /path/to/R.exe /path/to/rscriptfile ! means to invoke a shel command. Caveman On 12/1/08, Martin Weiss <[hidden email]> wrote: > > Line for the server... > > *********** > ssc d rsource > *********** > > HTH > Martin > > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of Ljubica > Nedelkoska > Sent: Monday, December 01, 2008 4:38 PM > To: [hidden email] > Subject: st: Invoking R from Stata > > Dear Statlist members, > > I would like to run a file written in R program from a Stata do file. I > would > appreciate if somebody helps me how to invoke R from Stata. > > Many thanks! > > Ljubica > > > > > > Ljubica Nedelkoska > PhD student > Research group: "Economics of Innovative Change" > Friedrich Schiller Universität-Jena > +49(0)3641 (9) 43 272 > > > > > > ---------------------------------------------------------------- > This mail was sent through http://webmail.uni-jena.de > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
Line for the server...
That is exactly what -rsource- does, but it also takes care of logging... HTH Martin -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Orvalho Augusto Sent: Monday, December 01, 2008 7:56 PM To: [hidden email] Subject: Re: st: RE: Invoking R from Stata Run from stata: ! /path/to/R.exe /path/to/rscriptfile ! means to invoke a shel command. Caveman On 12/1/08, Martin Weiss <[hidden email]> wrote: > > Line for the server... > > *********** > ssc d rsource > *********** > > HTH > Martin > > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of Ljubica > Nedelkoska > Sent: Monday, December 01, 2008 4:38 PM > To: [hidden email] > Subject: st: Invoking R from Stata > > Dear Statlist members, > > I would like to run a file written in R program from a Stata do file. I > would > appreciate if somebody helps me how to invoke R from Stata. > > Many thanks! > > Ljubica > > > > > > Ljubica Nedelkoska > PhD student > Research group: "Economics of Innovative Change" > Friedrich Schiller Universität-Jena > +49(0)3641 (9) 43 272 > > > > > > ---------------------------------------------------------------- > This mail was sent through http://webmail.uni-jena.de > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
Has anyone used _rsource_ with the Apple OS X operating system?
-Dave On Dec 1, 2008, at 1:00 PM, Martin Weiss wrote: > Line for the server... > > That is exactly what -rsource- does, but it also takes care of > logging... > > HTH > Martin > > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of Orvalho > Augusto > Sent: Monday, December 01, 2008 7:56 PM > To: [hidden email] > Subject: Re: st: RE: Invoking R from Stata > > Run from stata: > ! /path/to/R.exe /path/to/rscriptfile > > ! means to invoke a shel command. > > Caveman > > On 12/1/08, Martin Weiss <[hidden email]> wrote: >> >> Line for the server... >> >> *********** >> ssc d rsource >> *********** >> >> HTH >> Martin >> >> >> -----Original Message----- >> From: [hidden email] >> [mailto:[hidden email]] On Behalf Of Ljubica >> Nedelkoska >> Sent: Monday, December 01, 2008 4:38 PM >> To: [hidden email] >> Subject: st: Invoking R from Stata >> >> Dear Statlist members, >> >> I would like to run a file written in R program from a Stata do >> file. I >> would >> appreciate if somebody helps me how to invoke R from Stata. >> >> Many thanks! >> >> Ljubica >> >> >> >> >> >> Ljubica Nedelkoska >> PhD student >> Research group: "Economics of Innovative Change" >> Friedrich Schiller Universität-Jena >> +49(0)3641 (9) 43 272 >> >> >> >> >> >> ---------------------------------------------------------------- >> This mail was sent through http://webmail.uni-jena.de >> >> >> * >> * For searches and help try: >> * http://www.stata.com/help.cgi?search >> * http://www.stata.com/support/statalist/faq >> * http://www.ats.ucla.edu/stat/stata/ >> >> >> * >> * For searches and help try: >> * http://www.stata.com/help.cgi?search >> * http://www.stata.com/support/statalist/faq >> * http://www.ats.ucla.edu/stat/stata/ >> > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
In reply to this post by Orvalho Augusto
< >
Dave asked Has anyone used _rsource_ with the Apple OS X operating system? He is referring to Roger Newson's -rsource- package on SSC. I just tried it under Mac OS X 10.5 and it works fine. In Stata, do global Rterm_path "/usr/bin/r" global Rterm_options `"--vanilla"' Then if we have a file test.R containing ----- 2+2 q() ----- . rsource using test.R Assumed R program path: "/usr/bin/r" Beginning of R output from source file: test.R R version 2.6.2 (2008-02-08) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > 2+2 [1] 4 > q() End of R output from source file: test.R No doubt by changing the Rterm_options you can alter the way in which it produces output. Note that under *nix there is no separate executable Rterm; it is just the binary executable r. When you install R on Mac OS X, you get R.app, which is the executable that provides the GUI, but under the hood it calls /usr/bin/r. Kit Baum, Boston College Economics and DIW Berlin http://ideas.repec.org/e/pba1.html An Introduction to Modern Econometrics Using Stata: http://www.stata-press.com/books/imeus.html * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
On Dec 1, 2008, at 6:08 PM, Kit Baum wrote:
> No doubt by changing the Rterm_options you can alter the way in > which it produces output. Note that under *nix there is no > separate executable Rterm; it is just the binary executable r. When > you install R on Mac OS X, you get R.app, which is the executable > that provides the GUI, but under the hood it calls /usr/bin/r. Thanks, Kit: that is useful information that I was not aware of. Indeed, the help for R.app version 2.7.2 [1] suggests the following: "To use R you probably need to add a symbolic link on your system as the R binary is located inside the framework. Suppose you have the / usr/local/bin directory on your system (if you do not have one, you can use /usr/bin instead) you should just type in your Terminal (a root password is required) sudo ln -s /Library/Frameworks/R.framework/Resources/R /usr/ local/bin/R Assuming that you have /usr/local/bin in your PATH environment variable, you will be able to launch R from any location on your system just by typing R." -- Mike [1] I have not updated to version 2.8.0 due to some time series routines that do not yet execute properly with version 2.8.0. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
In reply to this post by Airey, David C
While I'm on the topic of platform independence....
I noticed from -help rsource- that the "Rterm_path" global macro of Roger Newson's -rsource- procedure defaults to a value of "Rterm.exe". In light of Kit Baum's response to David Airey (quoted below), it seems that a more robust solution would be to replace lines 30-32 of rsource.ado: if `"`rpath'"'=="" {; local rpath "Rterm.exe"; }; with the following: if `"`rpath'"'=="" {; if c(os) == "Windows" {; local rpath "Rterm.exe"; }; else {; local rpath "/usr/bin/r"; }; }; If I understand Kit's message correctly, the latter executable path is valid for any Unix-based installation of R (including R.app on Mac OS X). Hope this helps, Mike > On Dec 1, 2008, at 6:08 PM, Kit Baum wrote: >> He is referring to Roger Newson's -rsource- package on SSC. >> >> I just tried it under Mac OS X 10.5 and it works fine. In Stata, do >> >> global Rterm_path "/usr/bin/r" >> global Rterm_options `"--vanilla"' >> >> Then if we have a file test.R containing >> >> ----- >> 2+2 >> q() >> ----- >> >> . rsource using test.R >> Assumed R program path: "/usr/bin/r" >> >> >> Beginning of R output from source file: test.R >> >> R version 2.6.2 (2008-02-08) >> Copyright (C) 2008 The R Foundation for Statistical Computing >> ISBN 3-900051-07-0 >> >> R is free software and comes with ABSOLUTELY NO WARRANTY. >> You are welcome to redistribute it under certain conditions. >> Type 'license()' or 'licence()' for distribution details. >> >> Natural language support but running in an English locale >> >> R is a collaborative project with many contributors. >> Type 'contributors()' for more information and >> 'citation()' on how to cite R or R packages in publications. >> >> Type 'demo()' for some demos, 'help()' for on-line help, or >> 'help.start()' for an HTML browser interface to help. >> Type 'q()' to quit R. >> >> > 2+2 >> [1] 4 >> > q() >> >> End of R output from source file: test.R >> >> >> >> No doubt by changing the Rterm_options you can alter the way in >> which it produces output. Note that under *nix there is no >> separate executable Rterm; it is just the binary executable r. >> When you install R on Mac OS X, you get R.app, which is the >> executable that provides the GUI, but under the hood it calls /usr/ >> bin/r. >> >> Kit Baum, Boston College Economics and DIW Berlin >> http://ideas.repec.org/e/pba1.html >> An Introduction to Modern Econometrics Using Stata: >> http://www.stata-press.com/books/imeus.html >> On Dec 1, 2008, at 5:29 PM, David Airey wrote: > Has anyone used _rsource_ with the Apple OS X operating system? > > -Dave > > On Dec 1, 2008, at 1:00 PM, Martin Weiss wrote: > >> Line for the server... >> >> That is exactly what -rsource- does, but it also takes care of >> logging... >> >> HTH >> Martin >> >> >> -----Original Message----- >> From: [hidden email] >> [mailto:[hidden email]] On Behalf Of Orvalho >> Augusto >> Sent: Monday, December 01, 2008 7:56 PM >> To: [hidden email] >> Subject: Re: st: RE: Invoking R from Stata >> >> Run from stata: >> ! /path/to/R.exe /path/to/rscriptfile >> >> ! means to invoke a shel command. >> >> Caveman >> >> On 12/1/08, Martin Weiss <[hidden email]> wrote: >>> >>> Line for the server... >>> >>> *********** >>> ssc d rsource >>> *********** >>> >>> HTH >>> Martin >>> >>> >>> -----Original Message----- >>> From: [hidden email] >>> [mailto:[hidden email]] On Behalf Of Ljubica >>> Nedelkoska >>> Sent: Monday, December 01, 2008 4:38 PM >>> To: [hidden email] >>> Subject: st: Invoking R from Stata >>> >>> Dear Statlist members, >>> >>> I would like to run a file written in R program from a Stata do >>> file. I >>> would >>> appreciate if somebody helps me how to invoke R from Stata. >>> >>> Many thanks! >>> >>> Ljubica >>> >>> >>> Ljubica Nedelkoska >>> PhD student >>> Research group: "Economics of Innovative Change" >>> Friedrich Schiller Universität-Jena >>> +49(0)3641 (9) 43 272 >>> * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
Works for me. Thanks Kit and Mike.
-Dave On Dec 1, 2008, at 6:45 PM, Michael Hanson wrote: > While I'm on the topic of platform independence.... > > I noticed from -help rsource- that the "Rterm_path" global macro of > Roger Newson's -rsource- procedure defaults to a value of > "Rterm.exe". In light of Kit Baum's response to David Airey (quoted > below), it seems that a more robust solution would be to replace > lines 30-32 of rsource.ado: > > if `"`rpath'"'=="" {; > local rpath "Rterm.exe"; > }; > > with the following: > > if `"`rpath'"'=="" {; > if c(os) == "Windows" {; > local rpath "Rterm.exe"; > }; > else {; > local rpath "/usr/bin/r"; > }; > }; > > If I understand Kit's message correctly, the latter executable path > is valid for any Unix-based installation of R (including R.app on > Mac OS X). > > Hope this helps, > Mike > > >> On Dec 1, 2008, at 6:08 PM, Kit Baum wrote: >>> He is referring to Roger Newson's -rsource- package on SSC. >>> >>> I just tried it under Mac OS X 10.5 and it works fine. In Stata, do >>> >>> global Rterm_path "/usr/bin/r" >>> global Rterm_options `"--vanilla"' >>> >>> Then if we have a file test.R containing >>> >>> ----- >>> 2+2 >>> q() >>> ----- >>> >>> . rsource using test.R >>> Assumed R program path: "/usr/bin/r" >>> >>> >>> Beginning of R output from source file: test.R >>> >>> R version 2.6.2 (2008-02-08) >>> Copyright (C) 2008 The R Foundation for Statistical Computing >>> ISBN 3-900051-07-0 >>> >>> R is free software and comes with ABSOLUTELY NO WARRANTY. >>> You are welcome to redistribute it under certain conditions. >>> Type 'license()' or 'licence()' for distribution details. >>> >>> Natural language support but running in an English locale >>> >>> R is a collaborative project with many contributors. >>> Type 'contributors()' for more information and >>> 'citation()' on how to cite R or R packages in publications. >>> >>> Type 'demo()' for some demos, 'help()' for on-line help, or >>> 'help.start()' for an HTML browser interface to help. >>> Type 'q()' to quit R. >>> >>> > 2+2 >>> [1] 4 >>> > q() >>> >>> End of R output from source file: test.R >>> >>> >>> >>> No doubt by changing the Rterm_options you can alter the way in >>> which it produces output. Note that under *nix there is no >>> separate executable Rterm; it is just the binary executable r. >>> When you install R on Mac OS X, you get R.app, which is the >>> executable that provides the GUI, but under the hood it calls /usr/ >>> bin/r. >>> >>> Kit Baum, Boston College Economics and DIW Berlin >>> http://ideas.repec.org/e/pba1.html >>> An Introduction to Modern Econometrics Using Stata: >>> http://www.stata-press.com/books/imeus.html >>> > > On Dec 1, 2008, at 5:29 PM, David Airey wrote: > >> Has anyone used _rsource_ with the Apple OS X operating system? >> >> -Dave >> >> On Dec 1, 2008, at 1:00 PM, Martin Weiss wrote: >> >>> Line for the server... >>> >>> That is exactly what -rsource- does, but it also takes care of >>> logging... >>> >>> HTH >>> Martin >>> >>> >>> -----Original Message----- >>> From: [hidden email] >>> [mailto:[hidden email]] On Behalf Of Orvalho >>> Augusto >>> Sent: Monday, December 01, 2008 7:56 PM >>> To: [hidden email] >>> Subject: Re: st: RE: Invoking R from Stata >>> >>> Run from stata: >>> ! /path/to/R.exe /path/to/rscriptfile >>> >>> ! means to invoke a shel command. >>> >>> Caveman >>> >>> On 12/1/08, Martin Weiss <[hidden email]> wrote: >>>> >>>> Line for the server... >>>> >>>> *********** >>>> ssc d rsource >>>> *********** >>>> >>>> HTH >>>> Martin >>>> >>>> >>>> -----Original Message----- >>>> From: [hidden email] >>>> [mailto:[hidden email]] On Behalf Of Ljubica >>>> Nedelkoska >>>> Sent: Monday, December 01, 2008 4:38 PM >>>> To: [hidden email] >>>> Subject: st: Invoking R from Stata >>>> >>>> Dear Statlist members, >>>> >>>> I would like to run a file written in R program from a Stata do >>>> file. I >>>> would >>>> appreciate if somebody helps me how to invoke R from Stata. >>>> >>>> Many thanks! >>>> >>>> Ljubica >>>> >>>> >>>> Ljubica Nedelkoska >>>> PhD student >>>> Research group: "Economics of Innovative Change" >>>> Friedrich Schiller Universität-Jena >>>> +49(0)3641 (9) 43 272 >>>> > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
In reply to this post by Orvalho Augusto
< >
Michael said I noticed from -help rsource- that the "Rterm_path" global macro of Roger Newson's -rsource- procedure defaults to a value of "Rterm.exe". In light of Kit Baum's response to David Airey (quoted below), it seems that a more robust solution would be to replace lines 30-32 of rsource.ado: if `"`rpath'"'=="" {; local rpath "Rterm.exe"; }; with the following: if `"`rpath'"'=="" {; if c(os) == "Windows" {; local rpath "Rterm.exe"; }; else {; local rpath "/usr/bin/r"; }; }; If I understand Kit's message correctly, the latter executable path is valid for any Unix-based installation of R (including R.app on Mac OS X). I do have a symlink (ln -s) from a file within the R.app package to / usr/bin/r. I don't recall having made that link myself, and it is dated the same date as the directory R.app (yes, OS X .apps are really directories---as is Stata.app), so I imagine the R installer probably created the symlink (with my permission, as it is owned by root). It would be sensible for Roger N. to do something like local rpath = cond(c(os) == "Windows", "Rterm.exe", "/usr/bin/r") to make his routine platform-independent. Kit Baum, Boston College Economics and DIW Berlin http://ideas.repec.org/e/pba1.html An Introduction to Modern Econometrics Using Stata: http://www.stata-press.com/books/imeus.html * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
Free forum by Nabble | Edit this page |