| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/template.R |
| 3 |
\name{stitch} |
| 4 |
\alias{stitch} |
| 5 |
\alias{stitch_rhtml} |
| 6 |
\alias{stitch_rmd} |
| 7 |
\title{Automatically create a report based on an R script and a template} |
| 8 |
\usage{ |
| 9 |
stitch( |
| 10 |
script, |
| 11 |
template = system.file("misc", "knitr-template.Rnw", package = "knitr"), |
| 12 |
output = NULL, |
| 13 |
text = NULL, |
| 14 |
envir = parent.frame() |
| 15 |
) |
| 16 |
|
| 17 |
stitch_rhtml(..., envir = parent.frame()) |
| 18 |
|
| 19 |
stitch_rmd(..., envir = parent.frame()) |
| 20 |
} |
| 21 |
\arguments{ |
| 22 |
\item{script}{Path to the R script.} |
| 23 |
|
| 24 |
\item{template}{Path of the template to use. By default, the Rnw template in |
| 25 |
this package; there is also an HTML template in \pkg{knitr}.} |
| 26 |
|
| 27 |
\item{output}{Output filename, passed to \code{\link{knit}}). By default, |
| 28 |
the base filename of the script is used.} |
| 29 |
|
| 30 |
\item{text}{A character vector. This is an alternative way to provide the |
| 31 |
input file.} |
| 32 |
|
| 33 |
\item{envir}{Environment in which code chunks are to be evaluated, for |
| 34 |
example, \code{\link{parent.frame}()}, \code{\link{new.env}()}, or |
| 35 |
\code{\link{globalenv}()}).} |
| 36 |
|
| 37 |
\item{...}{Arguments passed to \code{stitch()}.} |
| 38 |
} |
| 39 |
\value{ |
| 40 |
path of the output document |
| 41 |
} |
| 42 |
\description{ |
| 43 |
This is a convenience function for small-scale automatic reporting based on |
| 44 |
an R script and a template. The default template is an Rnw file (LaTeX); |
| 45 |
\code{stitch_rhtml()} and \code{stitch_rmd()} are wrappers on top of |
| 46 |
\code{stitch()} using the R HTML and R Markdown templates respectively. |
| 47 |
} |
| 48 |
\details{ |
| 49 |
The first two lines of the R script can contain the title and author of the |
| 50 |
report in comments of the form \samp{## title:} and \samp{## author:}. The |
| 51 |
template must have a token \samp{\%sCHUNK_LABEL_HERE}, which will be used to |
| 52 |
input all the R code from the script. See the examples below. |
| 53 |
|
| 54 |
The R script may contain chunk headers of the form \samp{## ---- label, |
| 55 |
opt1=val1, opt2=val2}, which will be copied to the template; if no chunk |
| 56 |
headers are found, the whole R script will be inserted into the template as |
| 57 |
one code chunk. |
| 58 |
} |
| 59 |
\examples{ |
| 60 |
s = system.file("misc", "stitch-test.R", package = "knitr") |
| 61 |
if (interactive()) stitch(s) # compile to PDF |
| 62 |
|
| 63 |
# HTML report |
| 64 |
stitch(s, system.file("misc", "knitr-template.Rhtml", package = "knitr")) |
| 65 |
|
| 66 |
# or convert markdown to HTML |
| 67 |
stitch(s, system.file("misc", "knitr-template.Rmd", package = "knitr")) |
| 68 |
|
| 69 |
unlink(c("stitch-test.html", "stitch-test.md", "figure"), recursive = TRUE) |
| 70 |
} |
| 71 |
\seealso{ |
| 72 |
\code{\link{spin}} (turn a specially formatted R script to a report) |
| 73 |
} |