Knitr Reference Card

Knitr Reference Card

knitr Reference Card Yihui Xie September 8, 2021 1 Syntax 3 Chunk Options opts_chunk controls global chunk options, e.g. opts_chunk$set(tidy = FALSE), format start end inline output which can be overridden by local chunk options. See all options at https: Rnw <<*>>= @ \Sexpr{x} TEX //yihui.org/knitr/options/; some frequently used options: Rmd ```{r *} ``` `r x` MD Rhtml <!--begin.rcode * end.rcode--> <!--rinline x--> HTML eval whether to evaluate the chunk Rrst .. {r *} .. .. :r:`x` reST echo whether to echo source code Rtex % begin.rcode * % end.rcode \rinline{x} TEX results 'markup', 'asis', 'hold', 'hide' Rasciidoc // begin.rcode * // end.rcode +r x+ AsciiDoc tidy whether to reformat R code Rtextile ### begin.rcode * ### end.rcode @r x@ Textile cache whether to cache results brew <% x %> text g.width, g.height, out.width, out.height device and output size of gures include whether to include the chunk results in output * denotes local chunk options, e.g. <<label, eval=FALSE>>=; x denotes inline R child lenames of child documents code, e.g. `r 1+2` (MD stands for Markdown) engine language name (R, python, . ) 2 Minimal Examples 4 Functions knit() the main function in this package; knit input document and write output 2.1 Sweave (*.Rnw) 2.2 R Markdown (*.Rmd) purl() extract R code from an input document spin() spin goat's hair (an R script with roxygen comments) into wool (a literate Hi _markdown_! programming document to be passed to knit()) \documentclass{article} stitch() insert an R script into a template and compile the document \begin{document} ```{r foo, echo=TRUE} knit_hooks$set() set or reset chunk and output hooks z = 1+1 Below is a code chunk. plot(cars) <<foo, echo=TRUE>>= ``` 5 Resources z = 1+1 plot(cars) The value of z is `r z`. homepage: https://yihui.org/knitr/ @ development repository: https://github.com/yihui/knitr (CRAN, 2.3 Brew (*.brew) examples: https://github.com/yihui/knitr-examples The value of z is \Sexpr{z}. stackoverow: http://stackoverflow.com/tags/knitr/ \end{document} The value of pi is <% pi %>. mailing list: https://groups.google.com/group/knitr 1.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us