setup.APS.knitr {AnalysisPageServer} | R Documentation

## Set up knitr documents to contain AnalysisPageServer data sets

### Description

If you want to embed APS data sets within a knitr document then this function should be called at the top of the document like this:

### Usage

    setup.APS.knitr(outdir, include.css = system.file("AnalysisPageServer.css",
      package = "AnalysisPageServer"), include.toc = TRUE,
      libbase.prefix = get.APS.libbase.prefix(), quiet = TRUE)

### Arguments

`outdir` | Output directory to which front end files should be written. Default: see details.
`include.css` | Paths to CSS files to include. See details.
`include.toc` | Boolean, default TRUE. Should I include a table of contents?
`libbase.prefix` | Passed to `custom.html.headers`. Default: `get.APS.libbase.prefix()`.
`quiet` | Boolean, default TRUE. Set to FALSE to turn on some diagnostic messages

### Details

````{r echo = FALSE} AnalysisPageServer::setup.knitr() ````

Calling this function has the following effects:

1. The first effect is a heinous crime. It looks up the call stack to see if you are in the middle of a `buildVignettes` call. If so then it sets `clean = FALSE` for that call. The reason for this is that for the document to work it will need a bunch of auxiliary files like .css and .js, and if `clean = TRUE` then these files won't be left and your data sets will not show at all. During R CMD build `buildVignettes` is explicitly called with `clean = TRUE` so this is the only way I could figure out how to turn it off. If it can't find `buildVignettes` in the call stack then nothing special happens. This would be the case if you are just calling `knit2html` yourself.

2. The next effect is to copy all the front end files to the output directory. The default output directory is also kind of heinous. The files need to be next to the output file. So the function again looks up the call stack to find the `knit2html` call, then grabs the name of the `output` file from there and uses its directory as `outdir`. If it can't find a `knit2html` call then it throws an error.

   The output directory is saved with a call to the private function `set.APS.outdir`. This is then read back by `embed.APS.dataset` so that the data sets get written to the write place. You could add a `reset.APS.outdir()` call in a chunk at the bottom of your knitr document.

3. Any files in `include.css` are copied to the output directory and included as CSS. The default is a default stylesheet that will make your reports look like the vignettes.

Finally it returns the html headers as a "knit_asis" object to be included in your document. See `custom.html.headers`.

### Value

HTML headers as `knit_asis` objects.

### Author(s)

Brad Friedman

### Examples

    message("See vignette embedding.html")

[Package AnalysisPageServer version 1.18.1 Index]