spinstata {Statamarkdown} | R Documentation |
This function takes a Stata file containing special mark up in it's comments, and converts it to Markdown and HTML documents (or one of several other formats).
spinstata(statafile, text=NULL, keep=FALSE, ...)
statafile |
A character string with the name of a Stata "do" file, containing markup in it's comments. |
text |
A character string in place of a file. |
keep |
Whether to save intermediate files. |
... |
options passed to |
This function takes a Stata file containing special mark up in
it's comments, and converts it into knitr's "spin" format.
This is in turn sent to knitr::spin
, and converted to
Markdown and HTML (or one of several other formats).
Special Markup:
"/*' "
- Begin document text, ends with "'*/"
"/*+ "
- Begin chunk header, ends with "+*/"
"/*R "
- Begin a chunk of R code, ends with "R*/"
"*/* "
- Dropped from document, ends with
"*/*"
The path to the output file.
If given text instead of a file, returns the compiled document as a character string.
Doug Hemken
## Not run: indoc <- "/*' This is a special Stata script which can be used to generate a report. You can write normal text in command-style comments. First we specify a path for Stata and set up some options. '*/ /*+ setup +*/ /*R library(Statamarkdown) knitr::opts_chunk$set(engine.path=list(stata=find_stata()), comment=NA) R*/ /*' The report begins here. '*/ /*+ example1, engine='stata' +*/ sysuse auto /* Stata comment */ summarize /*' You can use the ***usual*** Markdown.'*/ " x<-spinstata(text=indoc) writeLines(x, "indoc.html") ## End(Not run)