[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
-rsource- does nothing more than launching R with a parameter and
capturing results, so no magic here: technically it does not run
r-code IN Stata, it runs r-code OUTSIDE of Stata, and Mr Newson
described that very specifically both in the title and description of
-rsource-. However, some still interpret that as "r-program will be
executed in Stata".
The trick would be to develop a easy and robust protocol of
communication between Stata and R. The easiest would be to write all
the parameters in a text file, and agree on the location of the
response (this can itself be a parameter). This should be no problem
if the function returns just a number, such as p-value, but if you
want more complex response (such as output, variables, etc) this must
be organized neatly.
I had something similar with Visual Basic, before switching to
plugins. Stata created a number of text files containing lists of
strings to process and passed the names of the lists and the name of
the response file to the Basic program. Then it patiently waited for
the file to be created (technically it waited for the flag-file,
before reading the response file, because when the response file
appears, it is not necessarily complete/closed).
On 5/30/08, Salah Mahmud <firstname.lastname@example.org> wrote:
> Dear all,
> Just wondering if you know of tried and tested Stata code (do or ado)
> that would run a piece of R code from within Stata and return certain
> pieces of the results as a Stata macro.
> For instance, I would like to call an R function that would perform
> certain calculations on certain variables (that also has to be
> exported to R) and then return certain pre-specified info (from the R
> object) such as a P-value as a Stata macro. Perhaps a combination of
> rsource, outsheet, some R object parsing and intext that hides all
> the mechanistic details of running R from within Stata.
> salah mahmud
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
* For searches and help try: