RMarkdown
?RStudio -> File -> New File ->R Markdown (keep defaults, add title)
code-type font
1. A numbered
1. List
1. Can be made
1. Like this
HTML Headers:
#Header 1
##Header 2
###Header 3
Delete default RMarkdown text (except global options)
# Add Some Notes
## Reflections on Markdown So Far
Markdown is **super** awesome, I'm *not* even joking.
Why I love `RMarkdown`:
1. It makes things reproducible
2. Easy to collaborate
3. It's fun!
Markdown is super awesome, I’m not even joking.
Why I love RMarkdown
:
Generate basic RMarkdown document.
[text to show](http://the-web-page.com)
![image caption](http://url/for/file)
F~2~
and super-script ( F2): F^2^
.$E=mc^2$
or formulas: \[y = \mu + \sum_{i=1}^p \beta_i x_i + \epsilon\] ($$y = \mu + \sum_{i=1}^p \beta_i x_i + \epsilon$$
).A main code chunk:
Place R code between the sets of ticks. You may also give each code chunk a name, which can help you find errors:
Can create a new code chunk manually (with backticks) or short-cut: CTRL+ALT+i.
[Importing surveys dataset into RMarkdown and creating a visualization with R code chunk options.]
library(ggplot2)
library(dplyr)
download.file("http://kbroman.org/datacarp/portal_clean.csv", "portal_clean.csv")
surveys <- read.csv("portal_clean.csv")
ggplot(surveys, aes(x=weight, y=hindfoot_length)) +
geom_point(aes(color=species_id, shape=sex)) +
facet_wrap(~year)
echo=FALSE
: supress code from being printed in final reportresults="hide"
: avoid having any results printed.eval=FALSE
: do not evaulate the code in the chunk.warning=FALSE
and message=FALSE
hides any warnings or messages produced.fig.height
, fig.width
controls size of figures (in inches).fig.cap
: adds a caption to the figures.fig.path
: defines path where figures will be saved. Example: ..., fig.path="Figs/",...
`r
and `
for an in-line code chunk.
`r round(some_value, 2)`
. The code will be executed and replaced with the value of the result.echo=FALSE
and results="hide"
(which is equivalent to include=FALSE
).surveys <- read.csv("portal_clean.csv")
There are `r nrow(surveys)` observations in the *surveys* dataset.
There are 30652 observations in the surveys dataset.
(May take some additional installation on your computer)
In addition to HTML documents, RMarkdown can also knit to PDF or Word documents.