문제

Is it possible to call Stata functions from R?

도움이 되었습니까?

해결책 2

There's now an RStata package on CRAN that bridges R and Stata.

다른 팁

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).

The real problem is that Stata doesn't have an interactive interpreter you can pass arguments to.

Dirk is right; you can just go ahead and write the data to a common format (if size is large and speed is an issue, fixed width is safe), but you can also just use .dta throughout the process, using read.dta in R and natively reading in Stata.

Also, in R you can call to the system() you can pass a do file or a string containing a bunch of Stata commands.

So, generally, trying to use Stata for this or that task may or may not be worth it, especially if an R equivalent is close by.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top