Yihui Xie
2013/07/29 @ VTN Stats Meeting
library(knitr)
# knit('input_file.ext'); for example
knit("whatever.Rmd") # ==> whatever.md
knit("whatever.Rnw") # ==> whatever.tex
#'
, and code as usual#+
system.file('examples', 'knitr-spin.R', package = 'knitr')
#' today I built a model
fit = lm(dist ~ speed, data = cars)
#' and I got the slope `r coef(fit)[2]`
#+ dist-speed, fig.width=5, fig.height=4
plot(cars)
abline(fit)
lazyLoad()
: do not load unless it is really used anywheredependson
: chunk B depends on chunk Adep_prev()
<<label>>
to embed one chunk into anotherref.label
child
knit_hooks$set(hook_name = function(x, options) { whatever you want})
knit_hooks$set(new_name = function(before, options, envir) { whatever you want })
engine
option, e.g. engine = 'python'
, engine = 'awk'
knitr-examples/.*engine.*.Rmd
(e.g. 023
)knit(text = 'construct your document here')
# ---- label, options ----
read_chunk()
data
, R
, man
, tests
, demo
, src
, vignettes
VignetteBuilder: knitr
in DESCRIPTION\VignetteEngine{knitr::knitr}
in vignettesbrowseVignettes(package = "knitr")
you will tell your colleagues
stop cut-and-paste! let's use knitr!