March 5, 2014
i.e. computing languages + authoring languages
We built a linear regression model. ```{r} fit <- lm(dist ~ speed, data = cars) b <- coef(fit) plot(fit) ``` The slope of the regression is `r b[1]`.
\section{Introduction} We did a \emph{cool} study.
<h1>Introduction</h1> <p>We did a <em>cool</em> study.</p>
\section{Introduction} We did a \emph{cool} study, and our main findings: \begin{enumerate} \item You can never remember how to escape backslashes. \item A dollar sign is \$, an ampersand \&, and a \textbackslash{}. \item How about ~? Use $\sim$. \end{enumerate}
# Introduction We did a _cool_ study, and our main findings: 1. You do not need to remember a lot of rules. 2. A dollar sign is $, an ampersand is &, and a backslash \. 3. A tilde is ~. Write content instead of markup languages.
We used to tell them "go to Pandoc".
Now we go to Pandoc and solve the problem directly.
# headers
, > blockquotes
_emphasis_
- lists
[links](url)
![images](url)
$\sum_{i=1}^n \alpha_i$
= \(\sum_{i=1}^n \alpha_i\)raw HTML/LaTeX
<div class="my-class"> ![image](url) </div> _emphasis_ and \emph{emphasis}
^[A footnote here.]
citations [@joe2014]
we used to call knitr and Pandoc separately
# in R library(knitr) knit('input.Rmd') # in command line pandoc -to beamer -o output.pdf –smart input.md
can be used as a standalone package as well (require separate Pandoc installation)
library(rmarkdown) render('input.Rmd') render('input.Rmd', pdf_document()) render('input.Rmd', word_document()) render('input.Rmd', beamer_presentation()) render('input.Rmd', ioslides_presentation())
--- title: "Sample Document" output: html_document: toc: true theme: united ---
This is equivalent to:
rmarkdown::render('input.Rmd', html_document(toc = TRUE, theme = 'united'))
html_document()
str(rmarkdown::html_document(), 2)
## List of 5 ## $ knitr :List of 3 ## ..$ opts_knit : NULL ## ..$ opts_chunk:List of 5 ## ..$ knit_hooks: NULL ## $ pandoc :List of 3 ## ..$ to : chr "html" ## ..$ from: chr "markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures" ## ..$ args: chr [1:5] "–section-divs" "–smart" "–self-contained" "–template" … ## $ clean_supporting: logi TRUE ## $ format_filter :function (output_format, files_dir, input_lines) ## $ post_processor : NULL ## - attr(*, "class")= chr "rmarkdown_output_format"
title: "Sample Document" output: my_nice_document: fig_width: 8 toc: true
my_nice_document()
is your own function that returns a list of knitr and Pandoc options.
You have done the hard work of research, data collection, and analysis, etc. We hope the last step can be easier.