-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chapters_26_to_30.Rmd
121 lines (91 loc) · 2.7 KB
/
Chapters_26_to_30.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
---
title: "Chapters 26 to 30"
author: "Laura"
date: "12/15/2019"
output:
html_document:
toc: true
number_sections: true
bibliography: rmd.bib
csl: apa.csl
params:
year:
label: "Year"
value: 2017
input: slider
min: 2010
max: 2018
step: 1
sep: ""
region:
label: "Region:"
value: Europe
input: select
choices: [North America, Europe, Asia, Africa]
printcode:
label: "Display Code:"
value: TRUE
data:
label: "Input dataset:"
value: results.csv
input: file
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, cache = TRUE)
library(tidyverse); library(skimr); library(nycflights13); library(GGally); library(ggstance); library(lvplot); library(hexbin); library(modelr); library(magrittr); library(maps); library(stringr); library(htmlwidgets); library(forcats); library(mapproj); library(lubridate); library(ggrepel); library(viridis)
```
# Notes for Chapters 26 to 30 - Communicate
## Chapter 27: RMarkdown
Text formatting
------------------------------------------------------------
*italic* or _italic_
**bold** __bold__
`code`
superscript^2^ and subscript~2~
* Bulleted list item 1
* Item 2
* Item 2a
* Item 2b
1. Numbered list item 1
1. Item 2. The numbers are incremented automatically in the output.
### Bibliography
Separate multiple citations with a `;`: Blah blah [@smith04; @doe99].
You can add arbitrary comments inside the square brackets:
Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].
Remove the square brackets to create an in-text citation: @smith04
says blah, or @smith04 [p. 33] says blah.
Add a `-` before the citation to suppress the author's name:
Smith says blah [-@smith04].
## Chapter 28: Graphics for communication
```{r}
ggplot(mpg, aes(displ, hwy)) +
geom_smooth(se = FALSE, method = "lm") +
geom_point(aes(color = class)) +
labs(title = "Blablabla",
caption = "mas bla",
subtitle = "un poco mas de blablaba",
x = paste("blablala ", quote(x^2 + alpha)), #esto andara en la pc con LaTeX? noup
color = "La Clase")
best <- mpg %>%
group_by(class) %>%
filter(hwy == max(hwy)) %>%
distinct(model, .keep_all = TRUE)
best
ggplot(mpg, aes(displ, hwy)) +
geom_smooth(se = FALSE, method = "lm") +
geom_point(aes(color = class)) +
geom_point(size = 3, shape = 1, data = best) +
geom_label_repel(data = best, aes(label = model))
```
```{r}
medians <- mpg %>%
group_by(class) %>%
summarise(hwy = median(hwy),
displ = median(displ))
ggplot(mpg, aes(displ, hwy, color = class)) +
geom_point() +
geom_label_repel(data = medians, aes(label = class), alpha = 0.5) +
theme(legend.position = "none")
```
## 28.4
# References