-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrmd-paper.Rmd
166 lines (137 loc) · 7.56 KB
/
rmd-paper.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
---
title: "Example paper from R Markdown"
author:
- name: Author 1
affiliation: University of Whatever
email: [email protected]
- name: Author 2
affiliation: University of Wherever
email: [email protected]
date: `r format(Sys.time(), '%d %B, %Y')`
published: Working paper.
title-page: true
git-repo: https://github.com/ygalanak/DataAnalysisTemplate
code-repo: "Access the code at <https://github.com/ygalanak/DataAnalysisTemplate>"
abstract: >-
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
reference-section-title: References
mainfont: Spectral
sansfont: Open Sans
thanks: >-
We thank x, y and $z$
keywords: k1; k2; k3
thanks: >-
I thank $x$, $y$. Financial support from $z$ is greatly acknowledged.
correspondence: >-
Correspondence concerning this article should be addressed to corresponding author. Contact: <[email protected]>.
---
<!-- rmd-paper.md is generated from rmd-paper.Rmd. Only edit the .Rmd file, *not* the .md file. -->
```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(
fig.path='figs-tbls',
cache.path='cache/',
dev=c("ragg_png","cairo_pdf"),
cache=TRUE,
par=TRUE,
echo=FALSE,
warning = FALSE,
results="asis",
message=FALSE)
knit_hooks$set(par = function(before, options, envir){
if (before && options$fig.show != 'none') par(mar = c(4,4,.1,.1), cex.lab = .95, cex.axis = .9, mgp = c(2, .7, 0), tcl = -.3)
}, crop=hook_pdfcrop)
opts_knit$set(kfigr.prefix=TRUE,
kfigr.link=FALSE)
# call in functions from `/scripts/`
source("scripts/001-HelperFunctions.R", local = knitr::knit_global())
# or sys.source("scripts/001-HelperFunctions.R", envir = knitr::knit_global())
# Load objects in study1.RData into my workspace
#load(file = "data/derived/myDerivedData.RData")
```
```{r libraries}
library(tidyverse)
library(gt)
library(here)
library(janitor)
library(socviz)
library(ggrepel)
library(showtext)
library(tibble)
library(magrittr)
library(pander)
library(gridExtra)
library(grid)
```
# Introduction
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua [@HeissKelley:2017]. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat [@KeckSikkink:1998]. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur [@Heiss:2019].
```{r build-save-plot, echo=FALSE, warning=FALSE}
# Technically, knitr can put graphic output directly in a document---that's like
# the number one thing knitr is famous for! For my workflow, though, I like
# creating all my images in other files, like an anlysis notebook, and then
# saving those figures with ggsave, since I can use Cairo to (1) embed fonts in
# PDFs and (2) use correct DPI in PNGs.
#
# Also (and more impotantly) with knitr it's impossible to add the cross
# reference metadata like {#fig:mpg-plot} that's necessary for pandoc-crossref.
#
# So instead, I make figures elsewhere (or even in the same document!), save
# them to disk using ggsave(), and then use standard Markdown syntax +
# pandoc-crossref metadata to include the images in my document.
set.seed(1234)
library(ggplot2)
plot1 <- ggplot(mpg, aes(x = cty, y = hwy, color = as.factor(cyl))) +
geom_point(size = 0.5, position = position_jitter()) +
labs(x = "City MPG", y = "Highway MPG", color = "Cylinders") +
theme_minimal(9)+
theme(axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8, face = "plain"),
legend.title=element_text(size=8))
plot1 <-arrangeGrob(plot1, nrow=1,
bottom = ggpubr::text_grob("Note: this plot really shows the same information, and is really very very very very long. \nSource: Authors' elaboration based on data",
x = 0,
y = 0.5,
just = "left",
size = 7, #font size
family = "sans"
))
ggsave(here::here("figs-tbls", "mpg-plot.pdf"), plot = plot1,
width = 5, height = 3, units = "in", device = cairo_pdf)
ggsave(here::here("figs-tbls", "mpg-plot.png"), plot = plot1,
width = 5, height = 3, units = "in", type = "cairo", dpi = 300)
```
{#fig:mpg-plot}
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam (see @fig:mpg-plot), eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
$$
\text{This is a test} = \beta_1 x_1 + \varepsilon
$$
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.
# New section
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?
## Subsection
In @tbl:mytable, quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
```{r example-table, echo=FALSE, warning=FALSE, message=FALSE}
# Unlike graphics, this can be done directly from R without needing to save an
# intermediate file if you want: set results="asis" in the chunk options,
# comment out pandoc.table.return() and cat(), and uncomment pandoc.table()
tribble(
~Heading, ~`Other heading`,
2, 3,
5, 7,
9, 1
) %>%
# pandoc.table(caption = "This is a table {#tbl:mytable}")
pandoc.table.return(caption = "This is a table {#tbl:mytable}") %>%
cat(file = here::here("figs-tbls", "mytable.md"))
```
!include figs-tbls/mytable.md
At vero eos et^[This is a footnote with an in-text reference @HeissKelley:2017.] accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio.
## Subsection again
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est^[This is a footnote.], omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
!include 'sections/conclusion.md'
\newpage
```{r sessioninfo, eval = FALSE}
# set eval = FALSE if you don't want this info (useful for reproducibility) to appear
sessionInfo()
# sessioninfo::session_info()
```