Differences between revisions 3 and 4
Revision 3 as of 2013-04-17 16:45:30
Size: 245
Editor: wifi
Comment:
Revision 4 as of 2013-04-17 16:55:57
Size: 1496
Editor: wifi
Comment:
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
[[http://yihui.name/knitr/|Knitr]] is an R package which allows direct embedding of code (R, Python, etc.) inside documents (LaTeX, HTML, Markdown, etc.). At the most basic level, this means no more copy and pasting or retyping of generated quantities, no more `\includegraphics{}` and `pdf()` or `ggsave()` calls in R, and no more typing scads of LMER coefficients.

What Knitr actually does is to scan the document, extract all the '''code chunks''', evaluate them, format the results in a nice way (that you can control), and insert them back into the document, which can then be compiled in whatever way is appropriate (`pdflatex` for a LaTeX document, or a web browser/markdown interpreter for HTML or markdown output).

Knitr is based on Sweave, but is a lot better. There's automatic cacheing (so that a document can be re-knit without re-running code that hasn't changed since the last knitting, like time-consuming data analysis code), more transparency (can include all input and output in the final document, as if you ran the code chunks in an R console), pretty formatting of R code and results in LaTeX, and a more modular interface which is easy to hack and expand.
Line 12: Line 18:
I can think of three reasons off the top of my head.
1.

Knitr: automatic report generation

What does it do?

Knitr is an R package which allows direct embedding of code (R, Python, etc.) inside documents (LaTeX, HTML, Markdown, etc.). At the most basic level, this means no more copy and pasting or retyping of generated quantities, no more \includegraphics{} and pdf() or ggsave() calls in R, and no more typing scads of LMER coefficients.

What Knitr actually does is to scan the document, extract all the code chunks, evaluate them, format the results in a nice way (that you can control), and insert them back into the document, which can then be compiled in whatever way is appropriate (pdflatex for a LaTeX document, or a web browser/markdown interpreter for HTML or markdown output).

Knitr is based on Sweave, but is a lot better. There's automatic cacheing (so that a document can be re-knit without re-running code that hasn't changed since the last knitting, like time-consuming data analysis code), more transparency (can include all input and output in the final document, as if you ran the code chunks in an R console), pretty formatting of R code and results in LaTeX, and a more modular interface which is easy to hack and expand.

Why would I want to do that??

I can think of three reasons off the top of my head. 1.

How do I do it?

LabmeetingSP13w13 (last edited 2013-10-16 03:31:19 by cpe-74-74-158-116)

MoinMoin Appliance - Powered by TurnKey Linux