Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Stata code to run R code from within Stata and return certain pieces of the results as Stata macros


From   "Salah Mahmud" <[email protected]>
To   [email protected]
Subject   Re: st: Stata code to run R code from within Stata and return certain pieces of the results as Stata macros
Date   Sat, 31 May 2008 10:37:51 -0500

Thanks Phil,

On Sat, May 31, 2008 at 9:52 AM, Phil Schumm wrote:
> Why go through a text file?  Why not just save a temporary file (in Stata
> format), and read it into R with the foreign package?

I agree that using the foreign lib allows for importation of variable
labels into R  etc but using simple text files has the advantage of
avoiding incompatibilities due to changing Stata file formats. Any
version of Stata and R is capable of importing/exporting text files.

>
> Note that this approach would not involve any interprocess communication
> between Stata and R, and would therefore be easily transferrable to all
> platforms on which both Stata and R run (since Python is easily available
> for all of these).

I like that. I think using text files or (perhaps XML) is preferable
to any solutions that would involve native OS-specific solutions.


> Now, Stata's complete set of data structures (i.e., variables, matrices,
> macros, scalars, etc.) is quite different from R's; moreover, figuring out
> how to move R's various types of result objects into Stata would take some
> serious work.  For this reason, a complete implementation of an abstraction
> layer would take *a lot* of work, and there may be some areas that simply
> cannot be addressed in a practical way.  Thus, if I were going to do this
> project, I'd start by creating an outline of what the abstraction layer
> might look like, and then pick just one, clearly defined area to implement
> first as a proof-of-concept.  This would, by itself, give you some
> functionality, and you could then decide whether and how to begin extending
> it.

The project that you describe is ambitious and definitely requires a
lot of work.  It would be great to be able to do all that but my
requirements are simpler because they only involve exporting Stata
data and  importing specific R memory elements.  This is even simpler
than the proof-of-concept  you proposed above.

Having said that, R is very versatile and like Stata has a vibrant
creative community. It is been awhile since the last time I researched
R capabilities and new packages so there might be an R package out
there that could do many of the more complicated tasks that were
discussed in this thread.

Thanks again,

/salah
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index