#acs.lookup(endyear=2012, span=1, table.number="B01001", keyword="Female")
v15 <- load_variables(2015, "acs5", cache = TRUE)
View(v15)
v19 <- load_variables(2019, "acs5", cache = TRUE)
View(v19)
us_components <- get_estimates(geography = "state", product = "components")
us_components
## # A tibble: 624 x 4
## NAME GEOID variable value
## <chr> <chr> <chr> <dbl>
## 1 Alabama 01 BIRTHS 59637
## 2 Alaska 02 BIRTHS 11335
## 3 Arizona 04 BIRTHS 86765
## 4 Arkansas 05 BIRTHS 38779
## 5 California 06 BIRTHS 500353
## 6 Colorado 08 BIRTHS 66345
## 7 Connecticut 09 BIRTHS 36319
## 8 Delaware 10 BIRTHS 11026
## 9 District of Columbia 11 BIRTHS 9652
## 10 Florida 12 BIRTHS 221755
## # ... with 614 more rows
unique(us_components$variable)
## [1] "BIRTHS" "DEATHS" "DOMESTICMIG"
## [4] "INTERNATIONALMIG" "NATURALINC" "NETMIG"
## [7] "RBIRTH" "RDEATH" "RDOMESTICMIG"
## [10] "RINTERNATIONALMIG" "RNATURALINC" "RNETMIG"
net_migration <- get_estimates(geography = "county",
variables = "RNETMIG",
geometry = TRUE,
shift_geo = TRUE)
## Please note: Alaska and Hawaii are being shifted and are not to scale.
library(tidycensus)
sc2015 <- get_estimates(
geography = "county",
product = "characteristics",
breakdown = c("RACE"),
breakdown_labels = TRUE,
state="06",
year = 2015) %>% filter(GEOID=="06085")
sc2018 <- get_estimates(
geography = "county",
product = "characteristics",
breakdown = c("RACE"),
breakdown_labels = TRUE,
state="06",
year = 2018) %>% filter(GEOID=="06085")
sc2015 <- arrange(sc2015,GEOID)
sc2018 <- arrange(sc2018,GEOID)
sc2018$change <- sc2018$value -sc2015$value
cs_2019 <- load_variables(2019, dataset = "acs1/profile")
viet <- cs_2019 %>%
filter(str_detect(label,pattern="Vietnamese"))
viet2019 <- get_acs(geography = "tract",variables = "DP05_0050",
state = "06",county = "085",year = 2019,geometry = TRUE) %>%
arrange(GEOID)
## Getting data from the 2015-2019 5-year ACS
## Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
## Using the ACS Data Profile
##
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============ | 18%
|
|============= | 18%
|
|============= | 19%
|
|============== | 19%
|
|============== | 20%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 22%
|
|================ | 23%
|
|================= | 24%
|
|================= | 25%
|
|================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 30%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 40%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 50%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 60%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 80%
|
|======================================================== | 81%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 90%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|==================================================================== | 98%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 100%
viet2015 <- get_acs(geography = "tract",variables = "DP05_0050",
state = "06",county = "085",year = 2015) %>%
arrange(GEOID)
## Getting data from the 2011-2015 5-year ACS
## Using the ACS Data Profile
viet2019$change <- viet2019$estimate - viet2015$estimate
#his <- cs_2019 %>% filter(str_detect(label,pattern="HISPANIC"))
#asian <- cs_2019 %>% filter(str_detect(label,pattern="Asian"))
ggplot(viet2019, aes(fill = change)) +
geom_sf(color="white")+
labs(title = "Vietnamese Population changes from 2015 to 2018 _ Census tracts",
subtitle = "Santa Clara County, CA")+
theme_void()
viet2019 <- arrange(viet2019,desc(change))
viet2019$NAME <- gsub(", Santa Clara County, California","",viet2019$NAME)
viet2019$NAME <- gsub("Census Tract","",viet2019$NAME)
top <- viet2019[1:25,]
top %>% ggplot( aes(fill=NAME, y=change, x=reorder(NAME,change))) +
geom_bar(position="dodge", stat="identity") +
theme(legend.position = "none")+
geom_text(aes(label=change), size=3,position=position_dodge(width=1)) + coord_flip() +
labs(title = "Population Increase _ from 2015 to 2018",subtitle = "Vietnamese Population",
x="Census tract",y="Santa Clara County, California")
top2 <- viet2019[26:50,]
top2 %>% ggplot( aes(fill=NAME, y=change, x=reorder(NAME,change))) +
geom_bar(position="dodge", stat="identity") +
theme(legend.position = "none")+
geom_text(aes(label=change), size=3,position=position_dodge(width=1)) + coord_flip() +
labs(title = "Population Increase _ from 2015 to 2018",subtitle = "Vietnamese Population",
x="Census tract",y="Santa Clara County, California")
top3 <- viet2019[51:75,]
top3 %>% ggplot( aes(fill=NAME, y=change, x=reorder(NAME,change))) +
geom_bar(position="dodge", stat="identity") +
theme(legend.position = "none")+
geom_text(aes(label=change), size=3,position=position_dodge(width=1)) + coord_flip() +
labs(title = "Population Increase _ from 2015 to 2018",subtitle = "Vietnamese Population",
x="Census tract",y="Santa Clara County, California")
top4 <- viet2019[76:100,]
top4 %>% ggplot( aes(fill=NAME, y=change, x=reorder(NAME,change))) +
geom_bar(position="dodge", stat="identity") +
theme(legend.position = "none")+
geom_text(aes(label=change), size=3,position=position_dodge(width=1)) + coord_flip() +
labs(title = "Population Increase _ from 2015 to 2018",subtitle = "Vietnamese Population",
x="Census tract",y="Santa Clara County, California")
top5 <- viet2019[101:125,]
top5 %>% ggplot( aes(fill=NAME, y=change, x=reorder(NAME,change))) +
geom_bar(position="dodge", stat="identity") +
theme(legend.position = "none")+
geom_text(aes(label=change), size=3,position=position_dodge(width=1)) + coord_flip() +
labs(title = "Population Increase _ from 2015 to 2018",subtitle = "Vietnamese Population",
x="Census tract",y="Santa Clara County, California")
viet2019[126:150,] %>%
ggplot( aes(fill=NAME, y=change, x=reorder(NAME,change))) +
geom_bar(position="dodge", stat="identity") +
theme(legend.position = "none")+
geom_text(aes(label=change), size=3,position=position_dodge(width=1)) + coord_flip() +
labs(title = "Population Increase _ from 2015 to 2018",subtitle = "Vietnamese Population",
x="Census tract",y="Santa Clara County, California")