
Last chance! 50% off unlimited learning
Sale ends in
#'
) and code chunk options are
written after #+
or #-
or # ----
.
spin(hair, knit = TRUE, report = TRUE, text = NULL, envir = parent.frame(), format = c("Rmd", "Rnw", "Rhtml", "Rtex", "Rrst"), doc = "^#+'[ ]?", inline = "^[{][{](.+)[}][}][ ]*$", comment = c("^[# ]*/[*]", "^.*[*]/ *$"), precious = !knit && is.null(text))
knit = FALSE
)hair
to
provide the R source; if text
is not NULL
, hair
will
be ignoredknit()
to evaluate the code##
to denote documentation, you can use
'^##\\s*'
((code))
on its own line is treated as an
inline expression/*
in the beginning and
*/
in the end of a line (following the convention of C comments).Rmd
files
when format
is "Rmd"
) should be preserved; default
FALSE
if knit == TRUE
and input is a filetext
is NULL
, the path of the final output document,
otherwise the content of the output.
stitch
(feed a template with an R script)
#' write normal text like this and chunk options like below
# + label, opt=value
# /*
#' these lines are treated as comments in spin()
1 + 1
# */
(s = system.file("examples", "knitr-spin.R", package = "knitr"))
spin(s) # default markdown
o = spin(s, knit = FALSE) # convert only; do not make a purse yet
knit2html(o) # compile to HTML
# other formats
spin(s, FALSE, format = "Rnw") # you need to write documentclass after #'
spin(s, FALSE, format = "Rhtml")
spin(s, FALSE, format = "Rtex")
spin(s, FALSE, format = "Rrst")
Run the code above in your browser using DataLab