-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.Rmd
216 lines (158 loc) · 6.87 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
---
Title: "Welcome to the `R` Coding Club"
header-includes: \usepackage{float}
always_allow_html: yes
output:
html_document
params:
lesson: "Index"
title: "Welcome to the `R` Coding Club"
---
<!-- ---------------------------------------------------------------- -->
<!-- ----------------------- rmd settings --------------------------- -->
<!-- ---------------------------------------------------------------- -->
```{r klippy, echo=FALSE, include=TRUE}
# klippy::klippy()
# rmarkdown::render_site() # render entire site
```
<!-- rmd settings -->
```{r, set-options, echo = FALSE, cache = FALSE}
options(width=100)
knitr::opts_chunk$set(
eval = TRUE, # run all code
# echo = FALSE, # show code chunks in output
comment = "",
tidy.opts=list(width.cutoff=100), # set width of code chunks in output
tidy=TRUE, # make output as tidy
message = FALSE, # mask all messages
warning = FALSE, # mask all warnings
size="small", # set code chunk size
knitr::opts_chunk$set(fig.pos = 'H')
)
```
<!-- install packages -->
```{r, load packages, include=T, cache=F, message=F, warning=F, results='hide',echo=F}
packages <- c("ggplot2","dplyr","tidyverse","zoo","RColorBrewer","viridis","plyr","leaflet")
if (require(packages)) {
install.packages(packages,dependencies = T)
require(packages)
}
lapply(packages,library,character.only=T)
```
<!-- ____________________________________________________________________________ -->
<!-- ____________________________________________________________________________ -->
<!-- ____________________________________________________________________________ -->
<!-- start body -->
# `r params$title`
\
<!-- ----------------------- overview --------------------------- -->
## Overview
This page contains all the documents, links, and information for the monthly `R` coding club held at Emory University, Atlanta. We meet monthly and teach new coding concepts and techniques in a casual environment. The club is half lesson half workshop style and caters for all coding and `R` levels.
Since Covid-19, the club has been virtual and all material remains online and free to distribute.
\
\
## Organisers
**Matt Malishev, Department of Biology**
**Desiree de Leon, Yerkes National Primate Research Center**
**Hasse Walum, Yerkes National Primate Research Center**
\
\
<!-- ----------------------- image --------------------------- -->
```{r, echo = FALSE, out.width = "33%", fig.align = "center", out.extra = "style = 'display: inline;'"}
knitr::include_graphics(c("img/mmm.jpg", "img/ddl.jpeg", "img/hw.jpg"))
```
<!-- ----------------------- image --------------------------- -->
<!-- \ -->
<!-- ## Date for next session -->
<!-- Time and day TBC -->
\
## Location
Emory University
Room 2052
Wayne Rollins Building
(Click on marker for room directions)
\
```{r,echo=F}
require(leaflet)
require(dplyr)
custom_tile <- "http://b.sm.mapstack.stamen.com/((mapbox-water,$f2f7ff[hsl-color]),(positron,$f2f7ff[hsl-color]),(buildings,$f2f7ff[hsl-color]),(parks,$2c403b[hsl-color]))/{z}/{x}/{y}.png"
latlon <- c(33.79667, -84.32346) # emory
ecc_label <- "Room 2052, Wayne Rollins Building"
ecc_popup <- "Take the elevator to the second floor, \nthen exit left and take the first left."
map <- leaflet() %>% # initiate the leaflet map object
setView(latlon[2],latlon[1],zoom=15) %>%
addTiles(custom_tile) %>% # add map tiles to the leaflet object
addMarkers(latlon[2],latlon[1],label=ecc_label,popup=ecc_popup)
map
```
\
<!-- ----------------------- 1 before arrival --------------------------- -->
# Before you arrive
Everyone needs to have the following software and packages loaded before you come to the first session. That way, we can get straight into it.
* [Install `R` from CRAN](https://www.r-project.org/).
+ If you're asked to choose a CRAN mirror, just choose whichever is closest to your location.
* [Install `RStudio` Desktop](https://www.rstudio.com/products/rstudio/download/)
* Install the `tidyverse` package and then load it by copying and pasting the following code into the *Console* of `RStudio` and then pressing *Enter* to execute it.
```{r, eval= FALSE}
install.packages("tidyverse")
library(tidyverse)
```
\
\
<br>
<!-- ----------------------- 3 learning obj --------------------------- -->
<a id="sec3"></a>
# Learning Objectives
The Coding Club will use the `R` tidyverse suite and packages. We will use base `R` for some of the fundamentals, with the idea of implementing tidyverse functions to learn more versatile, reproducible, and efficient code.
# Materials
We will use the [R for Data Science](https://r4ds.had.co.nz/index.html) free online text to guide us through learning `R`.
<!-- ----------------------- image --------------------------- -->
<div align="center"; text-align:center>
<img src="img/cover.png" style=width:33%>
</div>
<!-- ----------------------- image --------------------------- -->
<br>
# The dataset
We'll also be using [open-access data of housing listings from AirBnb](http://insideairbnb.com/new-york-city/) as our toy dataset. Once we've completed the above **R for Data Science exercises**, we'll repeat the plotting exercise using these data.
\
We'll be using this dataset for the rest of the club sessions, so feel free to explore it in your own time.
\
\
<!-- ----------------------- image --------------------------- -->
<div align="center"; text-align:center>
<img src="img/nyc.jpg" style=width:100%>
</div>
<!-- ----------------------- image --------------------------- -->
This is a really big data set (it has ~50k rows !!), so it will take a moment to run. To import the AirBnb data from the URL, copy and paste the lines of code below in your `R` console and press *Enter*.
```{r, eval = F}
# require(readr)
# url <- "http://data.insideairbnb.com/united-states/ny/new-york-city/2021-04-07/data/listings.csv.gz"
#
# nyc_full <- read_csv(url)
#
# # smaller csv file (16 cols)
# url <- "http://data.insideairbnb.com/united-states/ny/new-york-city/2021-04-07/data/listings.csv.gz"
# nyc <- read_csv(url)
# nyc <- nyc[nyc$id < 1000000,] # truncate dataset
#
# head(nyc[,1:5])
```
If everything worked correctly, you should see the below ouput printed in your `R` console.
```{r, echo=F, eval=T}
# smaller csv file (16 cols)
# url <- "http://data.insideairbnb.com/united-states/ny/new-york-city/2021-04-07/data/listings.csv.gz"
# nyc <- read_csv(url)
# nyc <- nyc[nyc$id < 1000000,] # truncate dataset
#
# head(nyc[,1:5])
```
\
\
#### Save and use the above code snippet whenever you need to load our two datasets, `nyc_full` and `nyc`, as we'll be using them regularly throughout the club sessions.
```{r, echo =FALSE, }
# devtools::install_github('yihui/xfun')
# a single RmD file
# xfun::embed_file('example.Rmd')
# embed a single csv file
# r xfun::embed_file('data.csv')`
```