Debian Codegraph @

man/spin.Rd

raw
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{
7 spin(
8 hair,
9 knit = TRUE,
10 report = TRUE,
11 text = NULL,
12 envir = parent.frame(),
13 format = c("Rmd", "Rnw", "Rhtml", "Rtex", "Rrst", "qmd"),
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
22 contains 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
30 R 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
37 default it follows the roxygen convention, but it can be customized, e.g.
38 if 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
42 default, code of the form \code{\{\{code\}\}} on its own line is treated as
43 an inline expression.}
44
45 \item{comment}{A pair of regular expressions for the start and end delimiters
46 of comments; the lines between a start and an end delimiter will be
47 ignored. By default, the delimiters are \verb{/*} at the beginning of a
48 line, and \verb{*/} at the end, following the convention of C comments.}
49
50 \item{precious}{logical: whether intermediate files (e.g., \code{.Rmd} files
51 when \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{
55 If \code{text} is \code{NULL}, the path of the final output document,
56 otherwise the content of the output.
57 }
58 \description{
59 This function takes a specially formatted R script and converts it to a
60 literate programming document. By default normal text (documentation) should
61 be written after the roxygen comment (\code{#'}) and code chunk options are
62 written after \code{#|} or \code{#+} or \code{# \%\%} or \code{# ----}.
63 }
64 \details{
65 Obviously the goat's hair is the original R script, and the wool is the
66 literate programming document (ready to be knitted).
67 }
68 \note{
69 If the output format is \code{Rnw} and no document class is specified
70 in roxygen comments, this function will automatically add the
71 \code{article} class to the LaTeX document so that it is complete and can
72 be compiled. You can always specify the document class and other LaTeX
73 settings in roxygen comments manually.
74
75 When the output format is \code{Rmd}, it is compiled to HTML via
76 \code{\link{knit2html}()}, which uses R Markdown v1 instead of v2. If you
77 want to use the latter, you should call
78 \code{rmarkdown::\link[rmarkdown]{render}()} instead. Similarly, if the
79 output format is \code{qmd}, you need to render the output with Quarto.
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{
88 Yihui 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 }