-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_data.Rmd
70 lines (58 loc) · 1.19 KB
/
map_data.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
---
title: "Map Tuition Data"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r message=FALSE}
library(tidyverse)
library(sf)
library(leaflet)
```
```{r}
tuition_fn <- "data/tuition.shp"
schools_fn <- "data/schools.shp"
```
```{r}
tuition <- tuition_fn %>% read_sf()
schools <- schools_fn %>% read_sf()
```
```{r}
combined <-
schools %>%
transmute(name = schl_nm, geometry) %>%
mutate(type = "school") %>%
rbind(
tuition %>%
select(name, geometry) %>%
mutate(type = "tuition")
)
```
```{r}
total_num_colours <-
tuition %>%
st_drop_geometry() %>%
distinct(curriculum) %>%
nrow()
```
```{r}
leaflet() %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addCircles(
color = ~ colorFactor(scales::hue_pal()(2), domain = combined$type)(type),
weight = 3,
label = ~ name,
data = combined
)
```
```{r}
# leaflet() %>%
# addProviderTiles(providers$CartoDB.Positron) %>%
# addCircles(
# color = ~ colorFactor(scales::hue_pal()(total_num_colours), domain = tuition$curriculum)(curriculum),
# weight = 3,
# label = ~ str_c(name, " (", curriculum, ")"),
# data = tuition
# )
```