Compile Census 2020 block data for all US states once downloaded and unzipped used by census2020_get_data()
Source: R/census2020_read.R
census2020_read.Rd
Compile Census 2020 block data for all US states once downloaded and unzipped
used by census2020_get_data()
Arguments
- folder
path
- filenumbers
a vector with any or all of 1,2,3 – default is file 1. File01 has Tables P1 and P2. File02 has Tables P3, P4, and H1. File03 has Table P5.
- mystates
can be vector of 2-letter abbreviations of states
- sumlev
default is 750, for blocks
- best_header_cols
default is a few key columns like POP100, GEOCODE (fips), etc.
- best_data_cols
default is key race ethnicity fields
Details
Not extensively tested. Attempts to read files already downloaded and unzipped, data files for specified states from the US Census Bureau's FTP site for Decennial Census file data.
Also look at the package totalcensus see Census website for list of possible fields etc.
for example:
# AREALAND Area (Land)
# AREAWATR Area (Water)
# BASENAME Area Base Name
# NAME Area Name-Legal/Statistical Area Description (LSAD) Term-Part Indicator
# FUNCSTAT Functional Status Code
# GCUNI Geographic Change User Note Indicator
# POP100 Population Count (100
# HU100 Housing Unit Count (100
# INTPTLAT Internal Point (Latitude)
# INTPTLON Internal Point (Longitude)
File 1 has Table P1 and
Table P2. HISPANIC OR LATINO, AND NOT HISPANIC OR LATINO BY RACE
Universe: Total population
P0020001 P0020002 P0020003 P0020004 P0020005 P0020006 P0020007 P0020008 P0020009 P0020010 P0020011 P0020012 P0020013 P0020014
Total: P0020001
Hispanic or Latino P0020002
Not Hispanic or Latino: P0020003
Population of one race: P0020004
White alone P0020005
Black or African American alone P0020006
American Indian and Alaska Native alone P0020007
Asian alone P0020008
Native Hawaiian and Other Pacific Islander alone P0020009
Some Other Race alone P0020010
Population of two or more races: Population of two races: P0020011
Examples
if (FALSE) { # \dontrun{
# library(census2020download)
census2020_download('./census2020zip', mystates = c('MD', 'DC'))
census2020_unzip('./census2020zip','./census2020out')
c2 <- census2020_read(folder = './census2020out', mystates = c('MD', 'DC'))
dim(c2)
str(c2)
head(c2)
sum(c2$POP100)
plot(
c2$INTPTLON[substr(c2$GEOCODE,1,2) == '24'],
c2$INTPTLAT[substr(c2$GEOCODE,1,2) == '24'], pch = '.')
c2$LOGRECNO <- NULL
colnames(c2) <- census2020download::census_col_names_map$Rname[
match(colnames(blocks2020), census2020download::census_col_names_map$ftpname)
]
} # }