-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
280 lines (188 loc) · 10.2 KB
/
index.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
---
title: |
{width=120px align=left style="padding-right: 20px"}
Introduction to R for Public Health Researchers
<br>
output:
html_document:
theme: spacelab
toc: false
toc_depth: 4
fig_caption: false
---
***
```{r setup, echo = FALSE, message = FALSE}
library(pander)
library(kableExtra)
library(tidyverse)
```
<style>#forkongithub a{background:#000;color:#fff;text-decoration:none;font-family:arial,sans-serif;text-align:center;font-weight:bold;padding:5px 40px;font-size:1rem;line-height:2rem;position:relative;transition:0.5s;}#forkongithub a:hover{background:#c11;color:#fff;}#forkongithub a::before,#forkongithub a::after{content:"";width:100%;display:block;position:absolute;top:1px;left:0;height:1px;background:#fff;}#forkongithub a::after{bottom:1px;top:auto;}@media screen and (min-width:800px){#forkongithub{position:fixed;display:block;top:0;right:0;width:200px;overflow:hidden;height:200px;z-index:9999;}#forkongithub a{width:200px;position:absolute;top:60px;right:-60px;transform:rotate(45deg);-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);box-shadow:4px 4px 10px rgba(0,0,0,0.8);}}</style><span id="forkongithub"><a href="https://github.com/jhudsl/intro_to_r">Fork me on GitHub</a></span>
<a href="http://www.jhsph.edu/"><img alt = "JHSPH" align="right" src="./images/bloomberg.logo.small.horizontal.blue.png" style="width:40%"/></a>
<br>
<br>
## Overview:
***
**Welcome to Introduction to R for Public Health Researchers!**
This course is for students who have little to no familiarity with the R programming language and want to learn more about how to use R to import, wrangle, visualize, and analyze data.
The course will provide students with **“hands-on” training** for analyzing data with the R programming language for statistical computing, a popular open-source solution for data analysis and visualization.
## Instructors:
***
* [Carrie Wright](https://carriewright11.github.io/): cwrigh60 at jhu.edu
* [Ava Hoffman](https://www.avahoffman.com/): ava.hoffman at jhu.edu
* [Candace Savonen](https://www.cansavvy.com/): csavone1 at jhu.edu
## TAs
***
* Grant Schumock - gschumo1 at jhmi.edu
* Qier Meng - qmeng11 at jhmi.edu
## Class:
***
* Jan 10-21, 2022, 8:30AM-11:50AM on Zoom - No class on Jan 17th for Martin Luther King Jr. Day.
* CoursePlus: https://courseplus.jhu.edu/core/index.cfm/go/syl:syl.public.view/coid/16733/
* [Syllabus](Syllabus/syllabus.html)
* [Syllabus (Word Document)](Syllabus/syllabus.docx)
## Zoom:
***
* Zoom link will be emailed to students
* Class sessions will be recorded and later posted
* We will have lectures as well as breakout room sessions to work on labs
* Please be aware that there is the option to use closed captioning:

* During lectures you can indicate how you feel about the pace of the course like so:

* In breakout room sessions you can ask for help like so:

* If you have a question based on our labs or homework (or not covered during lecture time), we ask that you post it on slack (which will be our main communication method - the link will be emailed). This allows for questions to be seen by everyone, not just the students in your breakout room. If another student does not answer your question (which we encourage!), we will try to answer it within 24 hours. If you feel uncomfortable posting a question publicly, let a TA or instructor know your question and we will post it for you anonymously.
```{r, child=c("Syllabus/_child_assignments.Rmd")}
```
```{r, child=c("Syllabus/_child_code_of_coduct.Rmd")}
```
## All the Requirements in this Course
***
#### Packages
We have an `R` package called `jhur` that will make sure all the packages are installed.
```r
install.packages("remotes")
remotes::install_github("muschellij2/jhur")
```
#### Data
All the data used that are not **specifically** to be downloaded from the web are located in [this zip file](data.zip), but we will show you how to read data from the internet as well.
## Schedule
***
```{r, child=c("Syllabus/_child_schedule.Rmd")}
```
```{r, results='asis', echo = FALSE, message=FALSE, warning = FALSE}
source("scripts/utils.R")
pander::pandoc.table(
read_markdown("Syllabus/_schedule_table.Rmd"),
missing = "",
split.tables = Inf,
style = "rmarkdown"
)
```
## Additional Resources
***
**Need help?**
- [Various "Cheat Sheets"](https://www.rstudio.com/resources/cheatsheets/)
- [R reference card](http://cran.r-project.org/doc/contrib/Short-refcard.pdf)
- [R jargon](https://link.springer.com/content/pdf/bbm%3A978-1-4419-1318-0%2F1.pdf)
- [R terminology](https://cran.r-project.org/doc/manuals/r-release/R-lang.pdf)
- [What is the Tidyverse?](https://www.tidyverse.org/packages/)
- [R Markdown formatting example](Examples/example_knitr.Rmd) and [html output](Examples/example_knitr.html)
- Animations of join functions:
[`full-join()`](https://github.com/gadenbuie/tidyexplain/blob/master/images/full-join.gif)
[`inner_join()`](https://github.com/gadenbuie/tidyexplain/blob/master/images/inner-join.gif)
[`left-join()`](https://github.com/gadenbuie/tidyexplain/blob/master/images/left-join.gif)
[`right-join()`](https://github.com/gadenbuie/tidyexplain/blob/master/images/right-join.gif)
- PC users who want to see how to move files around (especially from downloads), check out this video: https://youtu.be/we6vwB7DsNU
- Mac users who want to see how to move files around (especially from downloads), check out this video: https://www.youtube.com/watch?v=Ao9e0cDzMrE
**Want more?**
- [Tidyverse Skills for Data Science Book](https://jhudatascience.org/tidyversecourse/)
(more about the tidyverse, some modeling, and machine learning)
- [Tidyverse Skills for Data Science Course](https://www.coursera.org/specializations/tidyverse-data-science-r)
(same content with quizzes, can get certificate with $)
- [R for Data Science](http://r4ds.had.co.nz/)
(great general information)
- [Open Case Studies](https://www.opencasestudies.org/)
(resource for specific public health cases with statistical implementation and interpretation)
- [Dataquest](https://www.dataquest.io/)
(general interactive resource)
- [Quick R Guide]( http://statmethods.net/)
(nice free general resource)
- [Building up a `ggplot2` figure](https://hopstat.wordpress.com/2016/02/18/how-i-build-up-a-ggplot2-figure/)
(guide to making plots)
**Interested in Reproducibility?**
Check out Candace's courses:
- [Introduction](https://jhudatascience.org/Reproducibility_in_Cancer_Informatics/)
- [Advanced](https://jhudatascience.org/Adv_Reproducibility_in_Cancer_Informatics/)
**R for Stata, SPSS, and SAS files**
- The [Haven](https://haven.tidyverse.org/) package
(This package is super useful for reading and writing files so that they are compatible across Stata, SPSS, SAS, and R)
- [R vs Stata](https://link.springer.com/content/pdf/bbm%3A978-1-4419-1318-0%2F1.pdf)
(See page 505)
## Online Videos of Lectures
***
#### From Winter Institute 2020
```{r, echo = FALSE, message = FALSE, results='asis'}
mat = matrix(c(
"RStudio and Data Classes", "https://www.youtube.com/watch?v=vyIsDnsq5jY",
"Subsetting Data", "https://youtu.be/mT8lSagYbjM",
"Data Summarization Part 1", "https://www.youtube.com/watch?v=SZYpzt9zy0g",
"Data Classes", "https://www.youtube.com/watch?v=82zSA1N0mnA",
"Data Cleaning", "https://youtu.be/G3V2YPaQN34",
"Data Manipulation", "https://youtu.be/43MPdw5bf4o",
"Statistics 1", "https://www.youtube.com/watch?v=Jr4ljyzrr4U",
"Statistics 2", "https://youtu.be/ub2BSbK9lMM"
), ncol = 2, byrow = TRUE)
mat = data.frame(mat, stringsAsFactors = FALSE)
colnames(mat) = c("Day", "Link to Video")
knitr::kable(mat, format = "html") %>%
kable_styling()
```
#### From Summer Institute 1 2017
```{r videos, echo = FALSE, message = FALSE, results='asis'}
mat = matrix(c(
"Day 1", "https://youtu.be/Xi-wsACc7p0",
"Day 2", "https://youtu.be/u1FQt9Hr8iw",
"Day 3", "https://youtu.be/woc7AGJTzZw",
"Day 4", "https://youtu.be/RZ7eVIMPIes",
"Day 5", "https://youtu.be/e8cFV8wluC0"), ncol = 2, byrow = TRUE)
mat = data.frame(mat, stringsAsFactors = FALSE)
colnames(mat) = c("Day", "Link to Video")
knitr::kable(mat, format = "html") %>%
kable_styling()
```
## DHS Related things
***
[Example Script Reading in Stata DHS Data](dhs/example_dhs_reading.R)
DHS package:
```r
devtools::install_github("muschellij2/dhs")
```
<!-- ## How do I have `tidyverse` always loaded? -->
<!-- In `R`, if you have never set an `Renviron` before, you can make `tidyverse` load whenever you start `R` as follows: -->
<!-- ```{r, eval = FALSE} -->
<!-- filename = "~/.Renviron" -->
<!-- x = "" -->
<!-- if (file.exists(filename)) { -->
<!-- x = readLines(filename) -->
<!-- } -->
<!-- have_r_pack = grepl("R_DEFAULT_PACKAGES", x) -->
<!-- if (any(have_r_pack)) { -->
<!-- stop("add R_DEFAULT_PACKAGES to .Renviron manually!") -->
<!-- } else { -->
<!-- x = c('R_DEFAULT_PACKAGES="tidyverse"', x) -->
<!-- writeLines(x, con = filename) -->
<!-- } -->
<!-- ``` -->
<!-- ### Why NOT do this? -->
<!-- For reproducibility, you should still have `library(tidyverse)` at the top of your scripts so that if someone else (or you if you change computers) try to run the code, the code should still work. If you forget that, then the code is not reproducible and can be quite difficult to find this as the source of the problem. -->
## Find an Error!?
***
Feel free to submit typos/errors/etc via the github repository associated with the class:
https://github.com/jhudsl/intro_to_r_class
```{r, eval = FALSE, echo = FALSE}
## Render this file:
rmarkdown::render('index.Rmd')
```
This page was last updated on `r Sys.Date()`.
<p style="text-align:center;"><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://live.staticflickr.com/4557/26350808799_6f9c8bcaa2_b.jpg" height="150"/> </a> </p><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.