find_stata: A helper function that seeks to locate your Stata executable....

View source: R/find_stata.r

find_stataR Documentation

A helper function that seeks to locate your Stata executable. Ordinarily this is run automatically when Statamarkdown is loaded.

Description

This function searches for recent versions of Stata (>= Stata 11), in some of the usual default installation locations.

If Stata is not found, you will have to specify it's correct location yourself.

Usage

find_stata(message=TRUE)

Arguments

message

(logical) Whether or not to print a message when Stata is found.

Value

A character string with the path and name of the Stata executable.

Author(s)

Doug Hemken

See Also

Statamarkdown-package

Examples

indoc <- '
# An R console example
## In a first code chunk, set up with
```{r}
library(Statamarkdown)
```

## Then mark Stata code chunks with
```{stata}
sysuse auto, clear
generate gpm = 1/mpg
summarize price gpm
```
'

if (!is.null(Statamarkdown::find_stata())) {
  # To run this example, remove tempdir().
  fmd <- file.path(tempdir(), "test.md")
  fhtml <- file.path(tempdir(), "test.html")

  knitr::knit(text=indoc, output=fmd)
  rmarkdown::render(fmd, "html_document", fhtml)
}

Hemken/Statamarkdown documentation built on Dec. 11, 2023, 3:59 a.m.