1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/spin.R
3\name{spin}
4\alias{spin}
5\title{Spin goat's hair into wool}
6\usage{
7spin(
8  hair,
9  knit = TRUE,
10  report = TRUE,
11  text = NULL,
12  envir = parent.frame(),
13  format = c("Rmd", "Rnw", "Rhtml", "Rtex", "Rrst"),
14  doc = "^#+'[ ]?",
15  inline = "^[{][{](.+)[}][}][ ]*$",
16  comment = c("^[# ]*/[*]", "^.*[*]/ *$"),
17  precious = !knit && is.null(text)
18)
19}
20\arguments{
21\item{hair}{Path to the R script. The script must be encoded in UTF-8 if it
22contains multibyte characters.}
23
24\item{knit}{Logical; whether to compile the document after conversion.}
25
26\item{report}{Logical; whether to generate a report for \file{Rmd},
27\file{Rnw} and \file{Rtex} output. Ignored if \code{knit = FALSE}.}
28
29\item{text}{A character vector of code, as an alternative way to provide the
30R source. If \code{text} is not \code{NULL}, \code{hair} will be ignored.}
31
32\item{envir}{Environment for \code{\link{knit}()} to evaluate the code.}
33
34\item{format}{Character; the output format. The default is R Markdown.}
35
36\item{doc}{A regular expression to identify the documentation lines; by
37default it follows the roxygen convention, but it can be customized, e.g.
38if you want to use \code{##} to denote documentation, you can use
39\code{'^##\\\\s*'}.}
40
41\item{inline}{A regular expression to identify inline R expressions; by
42default, code of the form \code{\{\{code\}\}} on its own line is treated as
43an inline expression.}
44
45\item{comment}{A pair of regular expressions for the start and end delimiters
46of comments; the lines between a start and an end delimiter will be
47ignored. By default, the delimiters are \verb{/*} at the beginning of a
48line, and \verb{*/} at the end, following the convention of C comments.}
49
50\item{precious}{logical: whether intermediate files (e.g., \code{.Rmd} files
51when \code{format} is \code{"Rmd"}) should be preserved. The default is
52\code{FALSE} if \code{knit} is \code{TRUE} and the input is a file.}
53}
54\value{
55If \code{text} is \code{NULL}, the path of the final output document,
56  otherwise the content of the output.
57}
58\description{
59This function takes a specially formatted R script and converts it to a
60literate programming document. By default normal text (documentation) should
61be written after the roxygen comment (\code{#'}) and code chunk options are
62written after \code{#+} or \code{#-} or \code{# ----} or any of these
63combinations replacing \code{#} with \code{--}.
64}
65\details{
66Obviously the goat's hair is the original R script, and the wool is the
67literate programming document (ready to be knitted).
68}
69\note{
70If the output format is Rnw and no document class is specified in
71  roxygen comments, this function will automatically add the \code{article}
72  class to the LaTeX document so that it is complete and can be compiled. You
73  can always specify the document class and other LaTeX settings in roxygen
74  comments manually.
75
76  When the output format is Rmd, it is compiled to HTML via
77  \code{\link{knit2html}()}, which uses R Markdown v1 instead of v2. If you
78  want to use the latter, you should call
79  \code{rmarkdown::\link[rmarkdown]{render}()} instead.
80}
81\references{
82\url{https://yihui.org/knitr/demo/stitch/}
83}
84\seealso{
85\code{\link{stitch}} (feed a template with an R script)
86}
87\author{
88Yihui Xie, with the original idea from Richard FitzJohn (who named it
89  as \code{sowsear()} which meant to make a silk purse out of a sow's ear)
90}
91