Is it possible to call Stata functions from R?
To open a Stata file in R you can use the read_dta() function from the library called haven.
R and Stata are very different with regard to storing, accessing, and modifying data and variables. Stata only loads one data set at a time. R stores all object including data as objects and can have an arbitrary number loaded at once. Below I create an interaction term between x and z and a discrete version of x .
return add copies everything new in r() into return(). Say that your program performed a summarize. return add lets you add everything just returned by summarize to the to-be- returned results of your program. If your program had already set return(N), summarize's r(N) would not replace the previously set result.
Stata is both easy to learn and also very powerful. Stata is easy to learn in two ways. First, it offers a point-and-click interface that you can use if you do not know the name of a command, or the particulars of using it.
Not directly, i.e. there is no package I am aware of that implements a bridge.
You can always call external programs using system()
but that is neither elegant nor efficient. That said, you could prepare data in R, write it out, call Stata and then read the results in; see help(system)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With