spinstata {Statamarkdown}R Documentation

Convert a specially marked up Stata "do" file to Markdown and HTML.

Description

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

Usage

spinstata(statafile, text=NULL, keep=FALSE, ...)

Arguments

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 knitr::spin

Details

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:

Value

The path to the output file.

If given text instead of a file, returns the compiled document as a character string.

Author(s)

Doug Hemken

See Also

Statamarkdown-package

Examples

## Not run: 
indoc <- "/*'
# Statamarkdown Example

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 load Statamarkdown.
'*/

  /*+  setup +*/
  /*R
library(Statamarkdown)
R*/

  /*' The report begins here. '*/

  /*+  example1, engine='stata' +*/
  sysuse auto
/* Stata comment */
  summarize

/*' You can use the ***usual*** Markdown to mark up text.'*/
"
if (!is.null(Statamarkdown::find_stata())) {
  # To run this example, remove tempdir().
  fhtml <- file.path(tempdir(), "test.html")
  x<-Statamarkdown::spinstata(text=indoc)
  writeLines(x, fhtml)
}

## End(Not run)


[Package Statamarkdown version 0.9.2 Index]