doInStata | R Documentation |
Execute some Stata code in a running Stata instance
doInStata(id, code = "", df = NULL, import_df = !is.null(df),
results = c("e", "r"), timeout = Inf, preserve_restore = FALSE,
cleanup = TRUE, nolog = FALSE, future = FALSE)
id |
An object of S3 class 'StataID' generated by |
code |
A Stata code in a string to be executed |
df |
A data frame to be loaded into Stata before the Stata code is executed (optional) |
import_df |
Logical: should the resulting Stata dataset be returned?
Defaults: |
results |
NULL or a character vector with either |
timeout |
Seconds for R to wait for Stata results. Default: infinity. |
preserve_restore |
Logical: should the Stata code start with |
cleanup |
Logical: should the time-stamped temporary files (.do file, .log file, and possible input
and output .tsv files) be deleted at the end? Default: |
nolog |
Logical: should the Stata log be discarded in the returned value? Default: |
future |
Logical: should this function block R until Stata finishes the job and return what Stata
produces ( |
If future = FALSE
, a list with:
log
– A character vector with Stata display log
if nolog = FALSE
. May be an empty string if Stata does not finish executing
the code before timeout
.
error
– If Stata displays an error – an integer number with the Stata
error code number (see http://www.stata.com/manuals14/perror.pdf).
The error message should be visible in the log
(see the point above).
df
– Optional: a data frame saved by Stata if import_df = TRUE
and
if it can be read by read.delim
, else NULL
if read.delim
returns an error.
results
– if the argument results
is not NULL
, a list with
one or both of the elements named e_class
and/or r_class
(depending on what was specified in the argument results
), each including (if available):
scalars
– a named list of numeric scalar values,
macros
– a named list of character (string/text) values,
matrices
– a named list of numeric matrices,
modeldf
– only for e_class
: a data.frame with the estimated coefficients
(column coef
), and standard errors (column stderr
), with
the Stata variable names recorded in row.names.
If future = TRUE
, an object of S3 class 'StataFuture' to be used by
getStataFuture
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.