-
Notifications
You must be signed in to change notification settings - Fork 25
/
05-workshop_functions.Rmd
194 lines (142 loc) · 3.92 KB
/
05-workshop_functions.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
---
title: "What does this function do?"
subtitle: "Session 5"
institute: "NHS-R Community"
output:
xaringan::moon_reader:
css:
- default
- css/nhsr.css
- css/nhsr-fonts.css
lib_dir: libs
seal: false
self_contained: true
nature:
highlightStyle: googlecode
highlightLines: true
highlightLanguage: ["r"]
countIncrementalSlides: false
ratio: "16:9"
includes:
after_body: [css/insert-logo.html]
---
```{r libs, include=FALSE}
library(knitr)
library(tidyverse)
library(xaringan)
library(kableExtra)
library(icons)
library(xaringanExtra)
xaringanExtra::use_panelset()
xaringanExtra::use_clipboard()
xaringanExtra::use_share_again() # need to get the slide button on html view
opts_chunk$set(
echo = TRUE,
eval = FALSE,
message = FALSE,
warning = FALSE,
fig.width = 7.252,
fig.height = 4,
dpi = 300,
dev.args = list(type = "cairo")
)
```
class: title-slide, left, bottom
# `r rmarkdown::metadata$title`
----
## **`r rmarkdown::metadata$subtitle`**
### `r rmarkdown::metadata$author`
### `r rmarkdown::metadata$date`
.right-column[
]
---
# What does this function do?
<img class="center" src="img/session05/f1-for-help.PNG"/>
---
# In the console
Either in the script or in the console, typing ? before the function and run if the package is loaded:
```{r eval=FALSE}
?ggsave
```
Or if the package hasn't been loaded using the package::function() format:
```{r eval=FALSE}
?beepr::beep # is loaded in the Cloud
??beep # without the path requires two ?? to be global
```
---
# Getting help on Stackoverflow
... or [R Studio Community](https://community.rstudio.com/) or [NHS-R Slack group](https://nhsrcommunity.com/)
<img class="center" src="img/session05/stackoverflow_example.PNG"/>
---
# Cheat sheets
Popular packages have
[cheat sheets](https://rviews.rstudio.com/2021/03/10/rstudio-open-source-resorurces/) which are available as pdf downloads.
<img class="center" src="img/session05/cheat-sheets.PNG"/>
---
class: center, middle
# Save your script!
Think of your script (rather than the objects) as the "real" part of your analysis.
File `r icons::fontawesome("arrow-right")` Save As… `r icons::fontawesome("arrow-right")` ggplot_intro.R
Or shortcut <kbd>Ctrl + S</kbd>
---
# Recommended Reading
<img class="center" src="img/session05/recommended-reading.PNG"/>
http://socviz.co/
</br> https://serialmentor.com/dataviz/
</br> https://r4ds.had.co.nz/
All free online as well as available to buy as hardcopies
---
# Art interlude
https://twitter.com/accidental__aRt
</br>
--
</br>
</br>
## Computational aRt
https://art.djnavarro.net/
https://www.data-imaginist.com/art
---
```{r echo=FALSE, eval=TRUE, out.width="80%"}
lines <- tibble(
x = seq(0, 19, by = .5),
xend = x,
y = rep(0, 39),
yend = c(rep(c(5, 10), 19), 5))
dots <- lines %>%
select(x, yend)
ggplot() +
geom_segment(data = lines,
aes(x = x, xend = xend,
y = y, yend = yend),
color = "white") +
geom_point(data = dots,
aes(x = x, y = yend),
color = "white") +
scale_y_continuous(limits = c(-5, 10)) +
coord_polar() +
theme(
plot.background = element_rect(
fill = "#75926f"),
panel.background = element_rect(
fill = "#75926f"),
panel.grid = element_blank(),
plot.caption = element_text(
family = "Open Sans",
size = 6,
color = "white"),
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank()
)
```
[YouTube of the R Ladies talk](https://www.youtube.com/watch?v=h0i6KAahLY8)
[Source code](https://github.com/Ijeamakaanyene/aRt_ggplot)
[Slides](https://ijeamakaanyene.github.io/aRt_ggplot/index.html#1)
---
#### This work is licensed as
</br> Creative Commons
</br> Attribution
</br> ShareAlike 4.0
</br> International
</br> To view a copy of this license, visit
</br> https://creativecommons.org/licenses/by/4.0/