stata_engine {Statamarkdown} | R Documentation |
This function creates a modified Stata engine.
Set up once per session (i.e. document). Ordinarily this is run automatically when Statamarkdown is loaded.
stata_engine(options)
options |
|
This function is used as follows.
stata_engine(options)
is a language engine that returns Stata log output.
The end user should not need to use the language engine function directly. This is the workhorse function that actually calls Stata and returns output.
The language engine function returns Stata code and output internally to knitr.
Doug Hemken
## Not run: indoc <- ' # An R console example ## In a first code chunk, set up with ```{r} library(Statamarkdown) stataexe <- find_stata() knitr::opts_chunk$set(engine.path=list(stata=stataexe), error=TRUE, cleanlog=TRUE, comment=NA) ``` ## Then mark Stata code chunks with ```{stata, collectcode=TRUE} sysuse auto, clear generate gpm = 1/mpg summarize price gpm ``` ## A later chunk that depends on the first. ```{r, engine="stata", engine.path=stataexe} regress price gpm ``` ' # To run this example, remove tempdir(). fmd <- file.path(tempdir(), "test.md") fhtml <- file.path(tempdir(), "test.html") knitr::knit(text=indoc, output=fmd) markdown::markdownToHTML(fmd, fhtml) ## End(Not run)