You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -53,16 +53,20 @@ data, and other prerequisites you will need to work through the examples in this
53
53
54
54
This episode covers how to plot a raster in R using the `ggplot2`
55
55
package with customized coloring schemes.
56
-
It also covers how to layer a raster on top of a hillshade to produce
57
-
an eloquent map. We will continue working with the Digital Surface Model (DSM) raster
58
-
for the NEON Harvard Forest Field Site.
56
+
It also covers how to layer a raster on top of a hillshade to produce an
57
+
eloquent map. We will continue working with the Digital Surface Model (DSM)
58
+
raster for the NEON Harvard Forest Field Site.
59
59
60
60
## Plotting Data Using Breaks
61
61
62
62
In the previous episode, we viewed our data using a continuous color ramp. For
63
-
clarity and visibility of the plot, we may prefer to view the data "symbolized" or colored according to ranges of values. This is comparable to a "classified"
64
-
map. To do this, we need to tell `ggplot` how many groups to break our data into, and
65
-
where those breaks should be. To make these decisions, it is useful to first explore the distribution of the data using a bar plot. To begin with, we will use `dplyr`'s `mutate()` function combined with `cut()` to split the data into 3 bins.
63
+
clarity and visibility of the plot, we may prefer to view the data "symbolized"
64
+
or colored according to ranges of values. This is comparable to a "classified"
65
+
map. To do this, we need to tell `ggplot` how many groups to break our data
66
+
into, and where those breaks should be. To make these decisions, it is useful
67
+
to first explore the distribution of the data using a bar plot. To begin with,
68
+
we will use `dplyr`'s `mutate()` function combined with `cut()` to split the
69
+
data into 3 bins.
66
70
67
71
```{r histogram-breaks-ggplot}
68
72
@@ -74,15 +78,15 @@ ggplot() +
74
78
75
79
```
76
80
77
-
If we want to know the cutoff values for the groups, we can ask for the unique values
78
-
of `fct_elevation`:
81
+
If we want to know the cutoff values for the groups, we can ask for the unique
82
+
values of `fct_elevation`:
79
83
80
84
```{r unique-breaks}
81
85
unique(DSM_HARV_df$fct_elevation)
82
86
```
83
87
84
-
And we can get the count of values in each group using `dplyr`'s
85
-
`group_by()`and `count()` functions:
88
+
And we can get the count of values in each group using `dplyr`'s`group_by()`
89
+
and `count()` functions:
86
90
87
91
```{r breaks-count}
88
92
DSM_HARV_df %>%
@@ -93,8 +97,8 @@ DSM_HARV_df %>%
93
97
We might prefer to customize the cutoff values for these groups.
94
98
Lets round the cutoff values so that we have groups for the ranges of
95
99
301–350 m, 351–400 m, and 401–450 m.
96
-
To implement this we will give `mutate()` a numeric vector of break points instead
97
-
of the number of breaks we want.
100
+
To implement this we will give `mutate()` a numeric vector of break points
0 commit comments