-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.r
More file actions
49 lines (40 loc) · 993 Bytes
/
run.r
File metadata and controls
49 lines (40 loc) · 993 Bytes
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
# load packages ----
library(sf)
library(dplyr)
library(httr)
library(ggplot2)
library(ggthemes)
library(classInt)
library(mapview)
source("create-data.r")
source("my-func.r")
# create data for labels
myLabels <- ky_county_poly_join |>
filter(
life_expectancy %in% head(sort(ky_county_poly_join$life_expectancy), 20) |
pop10 %in% tail(sort(ky_county_poly_join$pop10), 10)
)
myPlot <- myPlotFun(ky_county_poly_join, life_expectancy_pretty)
myPlot
ggsave(
"export/myPlot.png",
width = 8,
height = 4,
units = "in"
)
# interactive map ----
myLabels <- glue::glue("County: {ky_county_poly_join$name2}<br />Life Expectancy: {ky_county_poly_join$life_expectancy}") |>
lapply(htmltools::HTML)
mapviewOptions(fgb = FALSE)
myInteractiveMap <- mapview(
ky_county_poly_join,
zcol = "life_expectancy",
label = myLabels
)
myInteractiveMap
# save files
# mapview::mapshot(
# myInteractiveMap,
# remove_controls = NULL,
# url = "exports/myInteractiveMap.html"
# )