-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounty_Script.R
More file actions
43 lines (28 loc) · 979 Bytes
/
County_Script.R
File metadata and controls
43 lines (28 loc) · 979 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
#To Clear working environment
rm(list=ls())
graphics.off()
library(tidyverse)
ggplot2::map_data()
mi_counties <- map_data("county", "michigan") %>% select(lon = long, lat, group, id = subregion)
head(mi_counties)
#You can visualise vector boundary data with geom_polygon():
ggplot(mi_counties, aes(lon, lat)) +
geom_polygon(aes(group = group)) +
coord_quickmap()
# Grey map
ggplot(mi_counties, aes(lon, lat)) +
geom_polygon(aes(group = group), fill = NA, colour = "grey50") + coord_quickmap()
tolower(dataframe$county)
#Create new county column
df2 <- df %>%
mutate(lower_county= county)
# dataframe$column_name
df2$lower_county <- tolower(df2$lower_county)
left_join(mi_counties ,df2,by...)
#ggplot
state_counties <- map_data("county") %>%
filter(region %in% c("michigan","california","florida")) %>%
select(lon = long, lat, group, id = subregion)
ggplot(state_counties, aes(lon, lat)) +
geom_polygon(aes(group = group)) +
coord_quickmap()