Instering census key

library(tidycensus);  library(tidyverse); library(sf)
## -- Attaching packages ---------------------------------------------------------------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 2.2.1.9000     v purrr   0.2.5     
## v tibble  1.4.2          v dplyr   0.7.5     
## v tidyr   0.8.1          v stringr 1.3.1     
## v readr   1.1.1          v forcats 0.3.0
## -- Conflicts ------------------------------------------------------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
## Linking to GEOS 3.6.1, GDAL 2.2.3, proj.4 4.9.3
v15_Profile <- load_variables(2015 , "acs5/profile", cache = TRUE) #demographic profile tables
v15_tables <- load_variables(2015 , "acs5", cache = TRUE) #all tables
#v10_sf1_tables <- load_variables(2010 , "sf1", cache = TRUE) #all tables for 2010 SF1
#v10_sf1_tables <- load_variables(2000 , "sf3", cache = TRUE) #all tables for 2000 SF#

#View(v15_Profile)
#Search for variables by 
v15_Profile[grep(x = v15_Profile$label,
                 
                 "HISP"
                 
                 ), c("name", "label")]
## # A tibble: 32 x 2
##    name        label                                                      
##    <chr>       <chr>                                                      
##  1 DP05_0065E  Estimate!!HISPANIC OR LATINO AND RACE!!Total population    
##  2 DP05_0065PE Percent!!HISPANIC OR LATINO AND RACE!!Total population     
##  3 DP05_0066E  Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!H~
##  4 DP05_0066PE Percent!!HISPANIC OR LATINO AND RACE!!Total population!!Hi~
##  5 DP05_0067E  Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!H~
##  6 DP05_0067PE Percent!!HISPANIC OR LATINO AND RACE!!Total population!!Hi~
##  7 DP05_0068E  Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!H~
##  8 DP05_0068PE Percent!!HISPANIC OR LATINO AND RACE!!Total population!!Hi~
##  9 DP05_0069E  Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!H~
## 10 DP05_0069PE Percent!!HISPANIC OR LATINO AND RACE!!Total population!!Hi~
## # ... with 22 more rows
v15_Profile[grep(x = v15_Profile$label,
                 
                 "Built 2000 to 2009"
                 
                 ), c("name", "label")]
## # A tibble: 2 x 2
##   name        label                                                       
##   <chr>       <chr>                                                       
## 1 DP04_0019E  Estimate!!YEAR STRUCTURE BUILT!!Total housing units!!Built ~
## 2 DP04_0019PE Percent!!YEAR STRUCTURE BUILT!!Total housing units!!Built 2~

DP05_0066PE is all Hispanic population proportion DP04_0019PE is all houses built between 2000 and 2009

Writing the files into local folders

sf::st_write(da_acs2,dsn="C:/Users/tobik/OneDrive/Documents/DEM7093 QGIS/Homework/HW_1",layer="da_tract_dp", driver="ESRI Shapefile", delete_layer=T, update=T)
## Deleting layer `da_tract_dp' using driver `ESRI Shapefile'
## Updating layer `da_tract_dp' to data source `C:\Users\tobik\OneDrive\Documents\DEM7093 QGIS\Homework\HW_1' using driver `ESRI Shapefile'
## features:       527
## fields:         11
## geometry type:  Multi Polygon
sf::st_write(ha_acs2,dsn="C:/Users/tobik/OneDrive/Documents/DEM7093 QGIS/Homework/HW_1",layer="ha_tract_dp", driver="ESRI Shapefile", delete_layer=T, update=T)
## Deleting layer `ha_tract_dp' using driver `ESRI Shapefile'
## Updating layer `ha_tract_dp' to data source `C:\Users\tobik\OneDrive\Documents\DEM7093 QGIS\Homework\HW_1' using driver `ESRI Shapefile'
## features:       784
## fields:         11
## geometry type:  Multi Polygon

Dallas County Hispanic Population Proportions

library(classInt)
library(patchwork)
library(dplyr)
library(ggplot2)

da_hisp_map<-da_acs2 %>%
  mutate(pHispanic = cut(Hispanic,breaks=data.frame(classIntervals(var=da_acs2$Hispanic, n=5, style="jenks")[2])[,1], include.lowest = T))


p1<-ggplot(da_hisp_map, aes(fill = pHispanic, color = pHispanic)) + 
  geom_sf() + 
  ggtitle("Proportion Hispanic", 
          subtitle = "Dallas County Texas, 2015 - Jenks Breaks")+
  coord_sf(crs =  102009) + 
  scale_fill_brewer(palette = "Blues") + 
  scale_color_brewer(palette = "Blues")+
  theme(axis.text.x = element_blank(), axis.text.y = element_blank())

p1

Harris County Hispanic Population Proportions

library(classInt)
library(patchwork)
library(dplyr)
library(ggplot2)

ha_hisp_map<-ha_acs2 %>%
  mutate(pHispanic = cut(Hispanic,breaks=data.frame(classIntervals(var=ha_acs2$Hispanic, n=5, style="jenks")[2])[,1], include.lowest = T))


p2<-ggplot(ha_hisp_map, aes(fill = pHispanic, color = pHispanic)) + 
  geom_sf() + 
  ggtitle("Proportion Hispanic", 
          subtitle = "Harris County Texas, 2015 - Jenks Breaks")+
  coord_sf(crs =  102009) + 
  scale_fill_brewer(palette = "Blues") + 
  scale_color_brewer(palette = "Blues")+
  theme(axis.text.x = element_blank(), axis.text.y = element_blank())

p2

Dallas County Housing Proportions built 2000-2009

library(classInt)
library(patchwork)
library(dplyr)
library(ggplot2)

da_hous_map<-da_acs2 %>%
  mutate(pHousing = cut(Housing,breaks=data.frame(classIntervals(var=da_acs2$Housing, n=5, style="jenks")[2])[,1], include.lowest = T))


p3<-ggplot(da_hous_map, aes(fill = pHousing, color = pHousing)) + 
  geom_sf() + 
  ggtitle("Proportion Houses built from 2000 to 2009", 
          subtitle = "Dallas County Texas, 2015 - Jenks Breaks")+
  coord_sf(crs =  102009) + 
  scale_fill_brewer(palette = "Blues") + 
  scale_color_brewer(palette = "Blues")+
  theme(axis.text.x = element_blank(), axis.text.y = element_blank())

p3

Harris County Housing Proportions built 2000-2009

library(classInt)
library(patchwork)
library(dplyr)
library(ggplot2)

ha_hous_map<-ha_acs2 %>%
  mutate(pHousing = cut(Housing,breaks=data.frame(classIntervals(var=ha_acs2$Housing, n=5, style="jenks")[2])[,1], include.lowest = T))


p4<-ggplot(ha_hous_map, aes(fill = pHousing, color = pHousing)) + 
  geom_sf() + 
  ggtitle("Proportion Houses built from 2000 to 2009", 
          subtitle = "Harris County Texas, 2015 - Jenks Breaks")+
  coord_sf(crs =  102009) + 
  scale_fill_brewer(palette = "Blues") + 
  scale_color_brewer(palette = "Blues")+
  theme(axis.text.x = element_blank(), axis.text.y = element_blank())

p4

Numerical Summary of Housing built from 2000 to 2009 and Hispanic Populations in Dallas and Harris County, Texas

## [1] "Dallas County Housing 2000-2009:"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    2.15    6.80   12.75   18.50   83.50
## [1] "Harris County Housing 2000-2009:"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    3.50   11.65   17.65   26.12   90.60
## [1] "Dallas County Hispanic Population:"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   16.20   33.50   37.65   57.00   96.20
## [1] "Harris County Hispanic Population:"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   20.68   35.70   41.50   60.40   97.40

Harris County had more buildings built from 2000 to 2009 in certain areas while Dallas County had a slightly higher mean. This might be because in Dallas County, contruction happend more evenly distributed.

Both Dallas County and Harris County have very similar distributions, means and medians. Harris County has a slightly larger Hispanic population.