

Stata_pwd = commandArgs(trailingOnly=TRUE) ĭf = read.dta("holderfile.dta", convert.f=TRUE) # Stata may mention an error anytime you include an R comment. # We're now in R, so switching the comment designation from star to hash Rsource, terminator("end_r_stata") roptions(`" -vanilla -args "`r_pwd'" "') ** Start R via rsource, pass your present working directory to it Saveold holderfile.dta, version(12) replace

** Temporarily make a copy of the dataset in a format R will probably understand ** This records Stata's present working directory in R-compatible format Find the location of Rterm.exe on your machine ** For sample purposes, let's use the auto dataset. It’s well commented below so you should be able to understand what it’s doing. Then you can use this code ( click here for download). You then need to change the line in the code that begins with global Rterm_path to wherever Rterm.exe is on your computer. For me, this is located in C:/Program Files/R/R-3.3.0/bin/圆4/Rterm.exe. Third, you need to find the R terminal program, named Rterm.exe.You can do this with the ssc inst rsource command. Second, you need the rsource package installed in Stata.
#Stata vs r install#
Install them using the install.packages() command, e.g. First, you need the foreign and ggplot2 packages installed in R.I’ve tested this with both Stata 13 and Stata 14 on Windows 7 on two different computers. This post walks you through exploiting ggplot2 directly from Stata. Stata is great, but it’s true that R makes prettier graphs, especially when you make use of the outstandingly excellent ggplot2 Thanks to Roger Newson we can have both.
