This discussion assumes you already have a basic understanding of Markdown for document formatting, Rmarkdown to include executable code in a document, and Stata to write the code.
Statamarkdown
libraryYour first code chunk will look something like this:
```r`r ''` library(Statamarkdown) ```
This will either report that Stata was found, or that you need to specify it\'s location yourself.
library(Statamarkdown)
You can hide all of this so it does not appear in your
final document by using the include=FALSE
chunk options.
You will need to specify this yourself, as additional lines in the \"library\" code block above.
stataexe <- "C:/Program Files/Stata18/StataSE-64.exe" # Windows # stataexe <- "/Applications/Stata/StataSE.app/Contents/MacOS/StataSE" # Mac OS # stataexe <- "/usr/local/stata18/stata-se" # Unix knitr::opts_chunk$set(engine.path = list(stata = stataexe))
If you do not know where to find you Stata executable (app),
open Stata and issue the command sysdir
. The line labeled
STATA:
is the folder where your Stata executable is located.
You can browse there with your computer\'s file explorer to
see the actual file name of the Stata executable, which varies
by operating system, Stata version, and Stata flavor.
Then make the Stata executable path a default chunk option.
A simple code chunk in Rmarkdown might look like:
```{stata example}`r ''` sysuse auto summarize ```
And in your document this would produce:
{stata example}
sysuse auto
summarize
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.