-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathR-ecology-lesson--04-visualization-ggplot2.diff
81 lines (72 loc) · 3.57 KB
/
R-ecology-lesson--04-visualization-ggplot2.diff
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
diff --git a/home/zhian/Documents/Carpentries/Git/zkamvar--postmaul/data/rmd-repos/datacarpentry--R-ecology-lessonR3/_site/04-visualization-ggplot2.md b/home/zhian/Documents/Carpentries/Git/zkamvar--postmaul/data/rmd-repos/datacarpentry--R-ecology-lessonR4/_site/04-visualization-ggplot2.md
index be3ee1a..b83d364 100644
--- a/home/zhian/Documents/Carpentries/Git/zkamvar--postmaul/data/rmd-repos/datacarpentry--R-ecology-lessonR3/_site/04-visualization-ggplot2.md
+++ b/home/zhian/Documents/Carpentries/Git/zkamvar--postmaul/data/rmd-repos/datacarpentry--R-ecology-lessonR4/_site/04-visualization-ggplot2.md
@@ -591,6 +591,13 @@ package provides a wide variety of options.
> yearly_weight <- surveys_complete %>%
> group_by(year, species_id) %>%
> summarize(avg_weight = mean(weight))
+> ```
+> :::
+>
+> #> `summarise()` regrouping output by 'year' (override with `.groups` argument)
+>
+> ::: {#cb33 .sourceCode}
+> ``` {.sourceCode .r}
> ggplot(data = yearly_weight, mapping = aes(x=year, y=avg_weight)) +
> geom_line() +
> facet_wrap(vars(species_id)) +
@@ -614,7 +621,7 @@ and think of ways you could improve the plot.
Now, let's change names of axes to something more informative than
'year' and 'n' and add a title to the figure:
-::: {#cb32 .sourceCode}
+::: {#cb34 .sourceCode}
``` {.sourceCode .r}
ggplot(data = yearly_sex_counts, aes(x = year, y = n, color = sex)) +
geom_line() +
@@ -632,7 +639,7 @@ The axes have more informative names, but their readability can be
improved by increasing the font size. This can be done with the generic
`theme()` function:
-::: {#cb33 .sourceCode}
+::: {#cb35 .sourceCode}
``` {.sourceCode .r}
ggplot(data = yearly_sex_counts, mapping = aes(x = year, y = n, color = sex)) +
geom_line() +
@@ -659,7 +666,7 @@ overlap. You can use a 90 degree angle, or experiment to find the
appropriate angle for diagonally oriented labels. We can also modify the
facet label text (`strip.text`) to italicize the genus names:
-::: {#cb34 .sourceCode}
+::: {#cb36 .sourceCode}
``` {.sourceCode .r}
ggplot(data = yearly_sex_counts, mapping = aes(x = year, y = n, color = sex)) +
geom_line() +
@@ -681,7 +688,7 @@ If you like the changes you created better than the default theme, you
can save them as an object to be able to easily apply them to other
plots you may create:
-::: {#cb35 .sourceCode}
+::: {#cb37 .sourceCode}
``` {.sourceCode .r}
grey_theme <- theme(axis.text.x = element_text(colour="grey20", size = 12,
angle = 90, hjust = 0.5,
@@ -725,7 +732,7 @@ plots using different variables or even different data frames. The
**`gridExtra`** package allows us to combine separate ggplots into a
single figure using `grid.arrange()`:
-::: {#cb36 .sourceCode}
+::: {#cb38 .sourceCode}
``` {.sourceCode .r}
library(gridExtra)
@@ -764,7 +771,7 @@ Instead, use the `ggsave()` function, which allows you easily change the
dimension and resolution of your plot by adjusting the appropriate
arguments (`width`, `height` and `dpi`):
-::: {#cb37 .sourceCode}
+::: {#cb39 .sourceCode}
``` {.sourceCode .r}
my_plot <- ggplot(data = yearly_sex_counts,
aes(x = year, y = n, color = sex)) +
@@ -791,7 +798,7 @@ ggsave("combo_plot_abun_weight.png", combo_plot, width = 10, dpi = 300)
Note: The parameters `width` and `height` also determine the font size
in the saved plot.
-Page built on: 📆 2020-07-24 ‒ 🕢 19:46:01
+Page built on: 📆 2020-07-24 ‒ 🕢 19:46:50
:::
------------------------------------------------------------------------