- results need to be reproducible
- Documentation of code
- easier to read and understand later on to extend
- Great for making reports as well
- Sharing results leads to facilitating discussion
- On literate programming:
- ..."consider programs to be works of literature"
- comprehensible programs --> better programs
- Also, because he's badass, made Tex for proper typesetting.
Some neat trivia
- version number approaches PI
- use to send people a byte of money ($2.56) for finding bugs
- WEB takes source file (of code and text)
- has 2 main functions
- Tangle
- compiles to an executable code file
- Weave
- compiles to documentation
- Tangle
- translates to HTML
- clear, concise
- at the cost of being somewhat restrictive
- almost as readable as the rendered HTML
- can convert between MANY different formats
markdown + pandoc leads to Knitr
Knitr runs in a separate environment
If you use markdown
- Can include things like videos, etc. using HTML
Can also use LaTex, and others as input
The rest of the talk is in reference to using Knitr with Rmarkdown
Like markdown syntax except
- hyphens up top delineate frontmatter/metadata in YAML
- for output options mostly
- Codeblocks can be passed options
Shortcut for codeblock in RStudio
- ctrl + alt + i
- cmd + alt + i
- make separate R files
- source them in the Knitr.
Use things like stargazer package
- By highlighting and right-clicking to run as with other code in RStudio
- using HTML commenting
<!-- any markdown including mix of text and codeblocks here -->
- cache option, if true
- doesn't re-eval itself if previous chunks has updated
- re-evals if changed within chunk
- can see in RStudio and use as navigation
- can reference code blocks elsewhere in document
Can write knitr hooks
- extra customization!
-
- learned about caching
-
For taking code from an explanation to use
- option of
knitr('filename', tangle=TRUE)
- option of
-
slides, with
ioslides_presentation
- whole workflow in Rmd
- do in RStudio first, then go to Rmarkdown
- sourcing a lot of R code chunks
- source one big file that sources other things
- Excel/Word with macros == sucked
- brittle, any small change = broken
- Rmarkdown is cleaner
- get to leverage the power of R
- for analysis
- for plots, graphs, etc
- easy to re-run anlysis and keep report in sync
- easier to publish online
- Difficult to have exact control over styles
- Lack of good
.ppt
generation for some audiences
- load.R, cleanup.R, figs.R, main.R
- source main that loads all
- custom ggplot theme
- customization can mean getting into css/html
Beamer for slides, and there are cool beamer themes
Brew is another way to do things like we saw with Knitr
- Takes more up front set up though
you can make knitr to mark new page \newpage
\newpage
is a feature of Tex
- "places knitr in context with functions and packages it plays nice with, and some alternatives"