/
blank_seal_code.R
59 lines (39 loc) · 1.24 KB
/
blank_seal_code.R
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
### SEAL DATA
# Set Up Software
library(dplyr)
library(ggplot2)
library(leaflet)
# Import Data
seals <- read.csv("seal_data.csv")
# Explore Data
# How many seals?
# How many seals per year?
# Can we turn this into a visualization?
seals %>%
group_by(year) %>%
summarise(total = sum(seals)) %>%
ggplot() +
geom_line(aes(x = year, y = total))
# What kind of terrain do seals prefer?
# fast ice = fastened to shore
# ice shelf = floating ice
# sea ice = frozen salt water
# Where was the data collected?
seal_data %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(radius = 3,
stroke = FALSE)
# Where do we see each type of ice?
terrain_pal <- colorFactor(c("red", "blue", "orange", "green"), seal_data$terrain)
seal_data %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(color = ~terrain_pal(terrain),
radius = 6,
stroke = FALSE) %>%
addLegend("bottomright", pal = terrain_pal, values = ~terrain)
# What area was surveyed each year?
year_pal <- colorFactor(c("red", "blue", "green", "purple"), seal_data$year)
# Where are seals actually found?
found_pal <- colorFactor(c("blue", "orange"), seal_data$seals > 0)