Skip to content

Commit

Permalink
update 2019 ACS 1 year
Browse files Browse the repository at this point in the history
  • Loading branch information
GL-Li committed Sep 26, 2020
1 parent 98dbc0a commit c33e6a3
Show file tree
Hide file tree
Showing 68 changed files with 38,890 additions and 166 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: totalcensus
Type: Package
Title: Extract Decennial Census and American Community Survey Data
Version: 0.6.3
Version: 0.6.4
Author: Guanglai Li
Maintainer: Guanglai Li <[email protected]>
Date: 2019-12-20
Date: 2020-09-26
Description: Download summary files from Census Bureau <https://www2.census.gov/>
and extract data, in particular high resolution data at
block, block group, and tract level, from decennial census and
Expand All @@ -15,7 +15,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.2.1)
R (>= 3.5.0)
Imports:
stringr (>= 1.2.0),
data.table (>= 1.10.1),
Expand All @@ -27,4 +27,4 @@ Suggests:
rmarkdown,
ggmap,
ggplot2
RoxygenNote: 7.0.2
RoxygenNote: 7.1.1
34 changes: 33 additions & 1 deletion R/data_acs.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,37 @@
"lookup_acs5year_2009"



# lookup_acs1year_2019 =========================================================
#' ACS 1-year 2019 file segment and table lookup data
#'
#' There is slightly difference in the lookup tables of each year.
#'
#' @docType data
#'
#' @format A data.table with 35527 rows and 7 variables
#' \describe{
#' \item{file_segment}{sequence number of segment data files, from "0001" to "0166"}
#' \item{table_content}{description of columns in a table}
#' \item{reference}{reference of the table content, such as "B01001_002". The reference
#' is used to extract data of table content.}
#' \item{restriction}{restrictions applied the the table_content}
#' \item{table_number}{table number such as "B01001"}
#' \item{table_name}{description of table. A table has multiple columns (table_content)}
#' \item{universe}{the universe of the data}
#' }
#'
#' @keywords datasets
#'
#' @source Check for each year of ACS 1-year and 5-year
#' \href{https://www.census.gov/programs-surveys/acs/technical-documentation/summary-file-documentation.2015.html}{Sequence Number/Table Number Lookup File}.
#'

"lookup_acs1year_2019"




# lookup_acs1year_2018 =========================================================
#' ACS 1-year 2018 file segment and table lookup data
#'
Expand Down Expand Up @@ -945,7 +976,8 @@
#' \describe{
#' \item{table_number}{table number such as "C27013"}
#' \item{table_name}{description of the table}
#' \item{acs1_2017}{whether the table is available in 2018}
#' \item{acs1_2019}{whether the table is available in 2019}
#' \item{acs1_2018}{whether the table is available in 2018}
#' \item{acs1_2017}{whether the table is available in 2017}
#' \item{acs1_2016}{whether the table is available in 2016}
#' \item{acs1_2015}{whether the table is available in 2015}
Expand Down
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Download summary files from [Census Bureau](https://www2.census.gov/) and extrac


## Update
**1/8/2020**: Version 0.6.3 is on CRAN. The 2018 ACS 5 year data was added to the package. The package now includes all latest data since 2000:
**9/26/2020**: Version 0.6.4 is on CRAN. The 2019 ACS 1 year data was added to the package. The package now includes all latest data since 2000:

- Decennial census 2000 and 2010
- ACS 1 year: 2005 - 2018
- ACS 1 year: 2005 - 2019
- ACS 5 year: 2009 - 2018


Expand Down
95 changes: 47 additions & 48 deletions application/E4_medium_home_values_all_block_groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,53 @@ library(data.table)
library(magrittr)
library(ggplot2)
library(ggmap)
goog_api <- Sys.getenv("GOOG_API_KEY")
goog_api <- Sys.getenv("GGMAP_GOOGLE_API_KEY")
register_google(goog_api)

# # national home value ==========================================================
# home_national <- read_acs5year(
# year = 2016,
# states = states_DC,
# # all 50 states plus DC
# table_contents = "home_value = B25077_001",
# summary_level = "block group"
# ) %>%
# .[!is.na(home_value)] %>%
# .[order(home_value)]
#
#
# us_map <- get_map("united states", zoom = 4, color = "bw")
#
# ggmap(us_map) +
# geom_point(
# data = home_national,
# # displace higher values
# aes(lon, lat, size = population, color = home_value),
# alpha = 1
# ) +
# ylim(25, 50) +
# scale_size_area(max_size = 0.05) +
# scale_color_continuous(
# low = "green",
# high = "red",
# breaks = c(100000, 500000, 1000000, 1500000, 2000000),
# labels = scales::unit_format("K", 1e-3)
# ) +
# guides(size = FALSE) +
# labs(color = "value ($)",
# caption = "Source: 2012-2016 ACS 5-year estimate",
# title = "Median Home Values in Each Block Group") +
# theme(
# panel.background = element_blank(),
# axis.title = element_blank(),
# axis.text = element_blank(),
# axis.ticks = element_blank(),
# legend.position = c(0.928, 0.197)
# )
#
# ggsave(filename = "application/national_home_value.png",
# width = 9, dpi = 600)
#
home_national <- read_acs5year(
year = 2018,
states = states_DC,
# all 50 states plus DC
table_contents = "home_value = B25077_001",
summary_level = "block group"
) %>%
.[!is.na(home_value)] %>%
.[order(home_value)]


us_map <- get_map("united states", zoom = 4, color = "bw")

ggmap(us_map) +
geom_point(
data = home_national,
# displace higher values
aes(lon, lat, size = population, color = home_value),
alpha = 1
) +
ylim(25, 49) +
scale_size_area(max_size = 0.05) +
scale_color_continuous(
low = "#00CCFF",
high = "red",
breaks = c(100000, 500000, 1000000, 1500000, 2000000),
labels = scales::unit_format(unit = "K", scale = 1e-3)
) +
guides(size = FALSE) +
labs(color = "value ($)",
caption = "Source: 2014-2018 ACS 5-year estimate",
title = "Median Home Values in Each Block Group") +
theme(
panel.background = element_blank(),
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
legend.position = c(0.928, 0.197)
)

ggsave(filename = "application/national_home_value.png",
width = 9, dpi = 600)


# New York home value ==========================================================
home_ny <- read_acs5year(
Expand Down Expand Up @@ -87,10 +87,9 @@ ggmap(ny_map) +
scale_size_area(max_size = 0.5) +
scale_color_continuous(
low = "green",
high = "red"
# ,
# breaks = c(100000, 500000, 1000000, 1500000, 2000000),
# labels = scales::unit_format("K", 1e-3)
high = "red",
breaks = c(100000, 500000, 1000000, 1500000, 2000000),
labels = scales::unit_format(unit = "K", scale = 1e-3)
) +
guides(size = FALSE) +
labs(color = "value ($)",
Expand Down
Binary file modified data/dict_acs1_table.RData
Binary file not shown.
Binary file added data/lookup_acs1year_2019.RData
Binary file not shown.
Loading

0 comments on commit c33e6a3

Please sign in to comment.