I have made the code for this document available for
download
Simply click the “code” button at the top of the
screen and download the RMD to save this file locally on your computer
or view the chunk-specific formatting throughout.
For more information on R Markdown formatting, visit this site: https://rmarkdown.rstudio.com/lesson-1.html
Or
download the R Markdown Cheat Sheet here: https://rmarkdown.rstudio.com/lesson-8.html
# Header 1
## Header 2
### Header 3
...
###### Header 6
*italics*
italics
**bold**
bold
`code box`
looks like a div container
superscript^2^/subscript~2~
superscript2/subscript2
~~strikethrough~~
strikethrough
Use <br> to force a line break (in html)
Or use double spaces at the end of the line to force one in word
apple
orange
- unordered list
- item 2
- item 2a (indent 1 tab)
- item 2b
ordered list
1. ordered list
2. item 2
- item 2a (indent 2 tabs)
- item 2b
ordered list
Three dashes in a row (---) create a line break like the one after this chunk.
Font colors can be changed in HTML, but word will ignore this formatting.
<span style="color: red;">This text will be red</span>
This text will be red
basic r plots are made with the formula plot()
car <- mtcars
plot(mpg ~ disp,
data = mtcars,
xlab = "Displacement (cu. in)",
ylab = "Miles per Gallon",
col = "hotpink")
By default plots will execute separately.
plot(mpg ~ disp,
data = mtcars,
xlab = "Displacement (cu. in)",
ylab = "Miles per Gallon",
col = "hotpink")
hist(mtcars$cyl,
col = "green4",
main = "Cylinder Count")
You can change this with par(mfrow)
The format of par(mfrow) is row, column, so this will print one on top of the other:
par(mfrow = c(2, 1))
plot(mpg ~ disp,
data = mtcars,
xlab = "Displacement (cu. in)",
ylab = "Miles per Gallon",
col = "hotpink")
hist(mtcars$cyl,
col = "green4",
main = "Cylinder Count")
And this will print side by side, but notice how it is left-aligned.
par(mfrow = c(1, 2))
plot(mpg ~ disp,
data = mtcars,
main = "MPG vs Displacement",
xlab = "Displacement (cu. in)",
ylab = "Miles per Gallon",
col = "hotpink")
hist(mtcars$cyl,
col = "green4",
main = "Cylinder Count")
Alignment is changed in the chunk.
{r, fig.align = ‘center’}
par(mfrow = c(1, 2))
plot(mpg ~ disp,
data = mtcars,
main = "MPG vs Displacement",
xlab = "Displacement (cu. in)",
ylab = "Miles per Gallon",
col = "hotpink")
hist(mtcars$cyl,
col = "green4",
main = "Cylinder Count")