Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: st: re: invoking R from Stata


From   Kit Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   re: st: re: invoking R from Stata
Date   Mon, 1 Dec 2008 18:08:34 -0500

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



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