-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
21 lines (21 loc) · 1.36 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
library(tidyverse)
library(sf)
countyoutflow <- read.csv("~/Desktop/elliesacbeeR/data/countyoutflow2021.csv")
us <- st_read("/Users/elin/Downloads/cb_2018_us_county_500k")
california <- countyoutflow %>% group_by(y2_countyname) %>% filter(y1_statefips == "6" & y2_statefips !=96 & y2_statefips !=97 & y2_statefips !=98)
california$y2_countyfips <- str_pad(california$y2_countyfips, 3, pad = 0)
california$y2_statefips <- str_pad(california$y2_statefips, 2, pad = 0)
california <- california %>% mutate(state2fullfips = str_c(y2_statefips, y2_countyfips))
us <- us %>% mutate(fullfips = str_c(STATEFP, COUNTYFP))
california %>% group_by(y2_countyname, state2fullfips) %>% summarise(individuals = sum(n2))
california %>% group_by(y2_countyname) %>% filter(y2_countyname == "Hennepin County") %>% summarise(individuals = sum(n2))
simplified <- california %>% group_by(y2_countyname, state2fullfips) %>% summarise(individuals = sum(n2))
uswithdata1 <- merge(us, simplified, by.x = "fullfips", by.y = "state2fullfips", all.x = TRUE)
st_write(uswithdata1, "uswithdata.shp")
uswithdata1 <- merge(us, simplified, by.x = "fullfips", by.y = "state2fullfips", all.x = TRUE)
st_write(uswithdata1, "uswithdata.shp")
st_write(uswithdata, "uswithdata.shp")
uswithdata <- merge(simplified, us, by.x = "state2fullfips", by.y = "fullfips")
st_write(uswithdata, "uswithdata.shp")
View(uswithdata1)
View(uswithdata)