-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample_article.Rmd
91 lines (74 loc) · 3.65 KB
/
example_article.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
output:
pdf_document:
citation_package: natbib
keep_tex: false
fig_caption: true
latex_engine: pdflatex
template: svm-latex-ms2.tex
title: "An Example Article"
thanks: "The paper's revision history and the materials needed to reproduce its analyses can be found [on Github here](http://github.com/fsolt/example_article). Corresponding author: [frederick-solt@uiowa.edu](mailto:frederick-solt@uiowa.edu). Current version: `r format(Sys.time(), '%B %d, %Y')`."
author:
- name: Frederick Solt
affiliation: University of Iowa
abstract: "Here's where you write 100 to 250 words, depending on the journal, that describe your objective, methods, results, and conclusion."
keywords: "these, always seem silly, to me, given google, but regardless"
date: "`r format(Sys.time(), '%B %d, %Y')`"
fontsize: 11pt
spacing: single
bibliography: \dummy{`r file.path(getwd(), list.files(getwd(), "bib$"))`}
biblio-style: apsr
citecolor: black
linkcolor: black
endnote: no
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
# load all the packages you will use below
library(dotwhisker)
library(tidyverse)
```
# Introduction to RMarkdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r mtcars}
summary(mtcars)
```
---
# This is a comment, set off with --- and started with #. Comments are good for notes to self that you don't want to show up in the output. Below is LaTeX code for a page break.
---
\pagebreak
## Including Plots
You can also embed plots, for example:
```{r dotwhisker_plot, fig.width = 7, fig.height = 4, warning = FALSE, message = FALSE, echo = FALSE, fig.cap="\\label{fig:dotwhisker_plot}Dot-and-Whisker Plot Example"}
m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
m2 <- update(m1, . ~ . + hp) # add another predictor
m3 <- update(m2, . ~ . + am) # and another
dwplot(list(m1, m2, m3),
vline = geom_vline(xintercept = 0, colour = "grey60", linetype = 2)) %>% # plot line at zero _behind_ coefs
relabel_predictors(c(wt = "Weight",
cyl = "Cylinders",
disp = "Displacement",
hp = "Horsepower",
gear = "Gears",
am = "Manual")) +
theme_bw() + xlab("Coefficient Estimate") + ylab("") +
geom_vline(xintercept = 0, colour = "grey60", linetype = 2) +
ggtitle("Predicting Gas Mileage") +
theme(plot.title = element_text(face="bold"),
legend.position = c(0.007, 0.01),
legend.justification = c(0, 0),
legend.background = element_rect(colour="grey80"),
legend.title = element_blank())
```
Figure \ref{fig:dotwhisker_plot} is a plot made using the \texttt{dotwhisker} package [@Solt2015c]. Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
## Citations
Want to cite something?
1. Find your cite key in your bib file.
1. Put an @ before it, like @Solt2017, or whatever it is
1. @Solt2017 creates an in-text citation
1. [@Herndon2014] creates a parenthetical citation
As @Gelman2014 note, the garden of forking paths can pose problems for researchers even when they are acting in good faith.
## Other Common Things
> This will create a block quote, if you want one.
Dropping a footnote is easy.^[See? Not hard at all.]