Evaluating Neighborhood Change

Chapter 1 - Data Wrangling

This chapter introduces some helper functions to query the Longitudinal Tracts Database (LTDB) to search for the variables you need for your analysis.

Library

#Library
library( tidyverse )
library( here )
library( pander )

Load LTDB Data

# Data

# store data dictionary file path
DD_FILEPATH <- here::here( "data/rodeo/ltdb_data_dictionary.csv" )

# import data dictionary
dd <- read.csv( DD_FILEPATH, stringsAsFactors=F)

# Longitudinal Tract Database 2010 Sample file path
LTDB_FILEPATH <- here::here( "data/raw/ltdb_std_2010_sample.csv" )

# Import Longitudinal Tract Database 2010 Sample 
ltdb.data <- read_csv( LTDB_FILEPATH, col_names = TRUE )

# Rename columns to lower case
ltdb.data <- as.data.frame( sapply( ltdb.data, tolower ) )

Load Helper Functions

# Load function source file
import::here("filter_category",
             "var_description",
             "filter_time",
             .from = here::here("analysis/source_file_rn.R"),
             .character_only = TRUE)

Sample Functions

# filter data where the category contains "race"
filter_category(dd, "race") %>% 
  pander()
Table continues below
  root root2 category definition
15 a15asn a15asn age-race 0-15 years old of Asians and Pacific Islanders (in 1980, 0-14 years old of Asians/Pacific Islanders; in 2008-12 ACS, 0-14 years old of Asian/Pacific Islander race)
16 a15blk a15blk age-race 0-15 years old of black race (in 1980, 0-14 years old of black race; in 2006- 10 ACS, 0-14 years old of black race)
17 a15hsp a15hsp age-race 0-15 years old, persons of Hispanic origins (in 1980, 0-14 years old, persons of Hispanic origin; in 2008-12 ACS, 0-14 years old, persons of Hispanic origins)
18 a15ntv a15ntv age-race 0-15 years old of Native American race (in 1980, 0-14 years old of Native American race; in 2008-12 ACS, 0-14 years old of Native American race)
19 a15wht a15wht age-race 0-15 years old of white race (in 1980, 0-14 years old of white race; in 2006- 10 ACS, 0-14 years old of white race)
21 a60asn a60asn age-race 60 years and older of Asians and Pacific Islanders
22 a60blk a60blk age-race 60 years and older of black race
23 a60hsp a60hsp age-race 60 years and older, persons of Hispanic origins
24 a60ntv a60ntv age-race 60 years and older of Native American race
26 a60wht a60wht age-race 60 years and older of white race
27 a65asn a65asn age-race 65 years and older of Asians and Pacific Islanders
28 a65blk a65blk age-race 65 years and older of black race
29 a65hsp a65hsp age-race 65 years and older, persons of Hispanic origins
30 a65ntv a65ntv age-race 65 years and older of Native American race
31 a65wht a65wht age-race 65 years and older of non-Hispanic whites
38 ageasn ageasn age-race Asian and Pacific Islander population with known age distribution
39 ageblk ageblk age-race black population with known age distribution
40 agehsp agehsp age-race Hispanic population with known age distribution
41 agentv agentv age-race Native American population with known age distribution
42 agewht agewht age-race white population with known age distribution
43 asian asian race persons of Asian race (and Pacific Islander)
44 black black race persons of black race
50 dapov dapov poverty-race Asians and Pacific Islanders for whom poverty status is determined
51 dbpov dbpov poverty-race black persons for whom poverty status is determined
55 dhpov dhpov poverty-race Hispanics for whom poverty status is determined
58 dnapov dnapov poverty-race Native American for whom poverty status is determined
60 dwpov dwpov poverty-race white persons for whom poverty status is determined
71 haw haw race persons of Hawaiian race
73 hha hha demographics-race total Asian/Pacific Islander households in sample-based data
74 hhb hhb demographics-race total black households in sample-based data
75 hhh hhh demographics-race total Hispanic households in sample-based data
76 hhw hhw demographics-race total white households in sample-based data
78 hinca hinca income-race Median household income for Asians and Pacific Islanders
79 hincb hincb income-race Median household income for blacks
80 hinch hinch income-race Median household income for Hispanics
81 hincw hincw income-race Median household income for whites
82 hisp hisp race persons of Hispanic origin
90 india india race persons of Asian Indian race
108 napov napov poverty-race Asians and Pacific Islanders in poverty
110 nbpov nbpov poverty-race blacks in poverty
112 nhblk nhblk race persons of black race, not Hispanic origin
113 nhpov nhpov poverty-race Hispanics in poverty
114 nhwht nhwht race persons of white race, not Hispanic origin
115 nnapov nnapov poverty-race Native Americans in poverty
117 ntv ntv race persons of Native American race
118 nwpov nwpov poverty-race whites in poverty
128 p15asn p15asn age-race percentage of 0-15 years old of Asians and Pacific Islanders (in 1980, percentage of 0-14 years old of Asians/Pacific Islanders; in 2008-12 ACS, percentage of 0-14 years old of Asian/Pacific Islander race)
129 p15blk p15blk age-race percentage of 0-15 years old of black race (in 1980, percentage of 0-14 years old of black race; in 2008-12 ACS, percentage of 0-14 years old of black race)
130 p15hsp p15hsp age-race percentage of 0-15 years old, persons of Hispanic origins (in 1980, percentage of 0-14 years old, persons of Hispanic origin; in 2008-12 ACS, percentage of 0-14 years old, persons of Hispanic origins)
131 p15ntv p15ntv age-race percentage of 0-15 years old of Native American race (in 1980, percentage of 0-14 years old of Native American race; in 2008-12 ACS, percentage of 0-14 years old of Native American race)
132 p15wht p15wht age-race percentage of 0-15 years old of white race (in 1980, percentage of 0-14 years old of white race; in 2008-12 ACS, percentage of 0-14 years old of white race)
136 p65asn p65asn age-race percentage of 65 years and older of Asians and Pacific Islanders
137 p65blk p65blk age-race percentage of 65 years and older of black race
138 p65hsp p65hsp age-race percentage of 65 years and older, persons of Hispanic origins
139 p65ntv p65ntv age-race percentage of 65 years and older of Native American race
140 p65pov p65pov age-race percentage of 65 years and older in poverty
141 p65wht p65wht age-race percentage of 65 years and older of non-Hispanic whites
143 papov papov poverty-race percentage of Asian and Pacific Islanders in poverty
144 pasian pasian race percentage of persons of Asian race (and Pacific Islander)
145 pbpov pbpov poverty-race percentage of blacks in poverty
156 phaw phaw race percentage of persons of Hawaiian race
157 phisp phisp race percentage of persons of Hispanic origin
158 phpov phpov poverty-race percentage of Hispanics in poverty
172 pnapov pnapov poverty-race percentage of Native Americans in poverty
174 pnhblk pnhblk race percentage of persons of black race, not Hispanic origin
175 pnhwht pnhwht race percentage of persons white, not Hispanic origin
176 pntv pntv race percentage of persons of Native American race
199 pwpov pwpov poverty-race percentage of whites in poverty
211 white white race persons of white race
Table continues below
  X1970.f X1970.s X1980.f X1980.s X1990.f X1990.s
15 a15asn80 A15ASN90
16 A15BLK70 a15blk80 A15BLK90
17 a15hsp80 A15HSP90
18 a15ntv80 A15NTV90
19 A15WHT70 a15wht80 A15WHT90
21 a60asn80 A60ASN90
22 A60BLK70 a60blk80 A60BLK90
23 a60hsp80 A60HSP90
24 a60ntv80 A60NTV90
26 A60WHT70 a60wht80 A60WHT90
27
28
29
30
31
38 ageasn80 AGEASN90
39 AGEBLK70 ageblk80 AGEBLK90
40 agehsp80 AGEHSP90
41 agentv80 AGENTV90
42 AGEWHT70 agewht80 AGEWHT90
43 ASIAN70 ASIAN80 ASIAN90
44 BLACK70
50 dapov80 DAPOV90
51 DBPOV70 dbpov80 DBPOV90
55 dhpov80 DHPOV90
58 dnapov80 DNAPOV90
60 DWPOV70 dwpov80 DWPOV90
71 HAW70 HAW80 HAW90
73 hha80 HHA90
74 hhb80 HHB90
75 hhh80 HHH90
76 hhw80 HHW90
78 hinca80 HINCA90
79 hincb80 HINCB90
80 hinch80 HINCH90
81 hincw80 HINCW90
82 HISP80 HISP90
90 INDIA70 INDIA80 INDIA90
108 napov80 NAPOV90
110 NBPOV70 nbpov80 NBPOV90
112 NHBLK80 NHBLK90
113 nhpov80 NHPOV90
114 NHWHT80 NHWHT90
115 nnapov80 NNAPOV90
117 NTV80 NTV90
118 NWPOV70 nwpov80 NWPOV90
128
129
130
131
132
136
137
138
139
140
141
143
144
145
156
157
158
172
174
175
176
199
211 WHITE70
  X2000.f X2000.s X2010.f X2010.s
15 A15ASN00 a15asn10 a15asn12
16 A15BLK00 a15blk10 a15blk12
17 A15HSP00 a15hsp10 a15hsp12
18 A15NTV00 a15ntv10 a15ntv12
19 A15WHT00 a15wht10 a15wht12
21 A60ASN00 a60asn10
22 A60BLK00 a60blk10
23 A60HSP00 a60hsp10
24 A60NTV00 a60ntv10
26 A60WHT00 a60wht10
27 a65asn12
28 a65blk12
29 a65hsp12
30 a65ntv12
31 a65wht12
38 AGEASN00 ageasn10 ageasn12
39 AGEBLK00 ageblk10 ageblk12
40 AGEHSP00 agehsp10 agehsp12
41 AGENTV00 agentv10 agentv12
42 AGEWHT00 agewht10 agewht12
43 ASIAN00 asian10 asian12
44
50 DAPOV00 dapov12
51 DBPOV00 dbpov12
55 DHPOV00 dhpov12
58 DNAPOV00 dnapov12
60 DWPOV00 dwpov12
71 HAW00 haw10 haw12
73 HHA00 hha12
74 HHB00 hhb12
75 HHH00 hhh12
76 HHW00 hhw12
78 HINCA00 hinca12
79 HINCB00 hincb12
80 HINCH00 hinch12
81 HINCW00 hincw12
82 HISP00 hisp10 hisp12
90 INDIA00 india10 india12
108 NAPOV00 napov12
110 NBPOV00 nbpov12
112 NHBLK00 nhblk10 nhblk12
113 NHPOV00 nhpov12
114 NHWHT00 nhwht10 nhwht12
115 NNAPOV00 nnapov12
117 NTV00 ntv10 ntv12
118 NWPOV00 nwpov12
128 p15asn12
129 p15blk12
130 p15hsp12
131 p15ntv12
132 p15wht12
136 p65asn12
137 p65blk12
138 p65hsp12
139 p65ntv12
140 p65pov12
141 p65wht12
143 papov12
144 pasian12
145 pbpov12
156 phaw12
157 phisp12
158 phpov12
172 pnapov12
174 pnhblk12
175 pnhwht12
176 pntv12
199 pwpov12
211
# search for variables containing the description "60 years and older"
var_description(dd, "60 years and older")

## [1] "a60asn" "a60blk" "a60hsp" "a60ntv" "a60wht"

# create a vector containing the time period (start, end)
time_period <- c("1990","2000")

# filter data to show all variables available for the time period 
filter_time( dd, time_period) %>% pander()
Table continues below
root category definition 1990
state id state state
county id county county
tract id census tract tract
trtid id census tract (10 digit identifier) TRTID10
cbsa tract attribute A core-based statistical area (CBSA) is a U.S. geographic area defined by the Office of Management and Budget (OMB) that consists of one or more counties (or equivalents) anchored by an urban center of at least 10,000 people plus adjacent counties that are socioeconomically tied to the urban center by commuting cbsa10
ccflag tract attribute ccflag10
metdiv tract attribute Metropolitan Division metdiv10
placefp tract attribute 5-character place FIPS code placefp10
globd tract attribute GlobD90
globg tract attribute GlobG90
placefp tract attribute 5-character place FIPS code placefp10
cbsa tract attribute A core-based statistical area (CBSA) is a U.S. geographic area defined by the Office of Management and Budget (OMB) that consists of one or more counties (or equivalents) anchored by an urban center of at least 10,000 people plus adjacent counties that are socioeconomically tied to the urban center by commuting cbsa10
metdiv tract attribute Metropolitan Division metdiv10
ccflag tract attribute ccflag10
a15asn age-race 0-15 years old of Asians and Pacific Islanders (in 1980, 0-14 years old of Asians/Pacific Islanders; in 2008-12 ACS, 0-14 years old of Asian/Pacific Islander race) A15ASN90
a15blk age-race 0-15 years old of black race (in 1980, 0-14 years old of black race; in 2006- 10 ACS, 0-14 years old of black race) A15BLK90
a15hsp age-race 0-15 years old, persons of Hispanic origins (in 1980, 0-14 years old, persons of Hispanic origin; in 2008-12 ACS, 0-14 years old, persons of Hispanic origins) A15HSP90
a15ntv age-race 0-15 years old of Native American race (in 1980, 0-14 years old of Native American race; in 2008-12 ACS, 0-14 years old of Native American race) A15NTV90
a15wht age-race 0-15 years old of white race (in 1980, 0-14 years old of white race; in 2006- 10 ACS, 0-14 years old of white race) A15WHT90
a18und age persons age 17 years and under A18UND90
a60asn age-race 60 years and older of Asians and Pacific Islanders A60ASN90
a60blk age-race 60 years and older of black race A60BLK90
a60hsp age-race 60 years and older, persons of Hispanic origins A60HSP90
a60ntv age-race 60 years and older of Native American race A60NTV90
a60up age persons age 60 years and over A60UP90
a60wht age-race 60 years and older of white race A60WHT90
a75up age persons age 75 years and over A75UP90
ageasn age-race Asian and Pacific Islander population with known age distribution AGEASN90
ageblk age-race black population with known age distribution AGEBLK90
agehsp age-race Hispanic population with known age distribution AGEHSP90
agentv age-race Native American population with known age distribution AGENTV90
agewht age-race white population with known age distribution AGEWHT90
asian race persons of Asian race (and Pacific Islander) ASIAN90
china ethnicity persons of Chinese race CHINA90
cuban ethnicity Cubans CUBAN90
filip ethnicity persons of Filipino race FILIP90
haw race persons of Hawaiian race HAW90
hisp race persons of Hispanic origin HISP90
hu housing housing units HU90
india race persons of Asian Indian race INDIA90
japan ethnicity persons of Japanese race JAPAN90
korea ethnicity persons of Korean race KOREA90
mex ethnicity Mexicans MEX90
nhblk race persons of black race, not Hispanic origin NHBLK90
nhwht race persons of white race, not Hispanic origin NHWHT90
ntv race persons of Native American race NTV90
ohu housing occupied housing units OHU90
own housing owner-occupied housing units OWN90
pop demographics total population POP90
pr ethnicity Puerto Ricans PR90
rent housing renter-occupied housing units RENT90
vac housing vacant housing units VAC90
viet ethnicity persons of Vietnamese race VIET90
2000
state
county
tract
TRTID10
cbsa10
ccflag10
metdiv10
placefp10
GlobD00
GlobG00
placefp10
cbsa10
metdiv10
ccflag10
A15ASN00
A15BLK00
A15HSP00
A15NTV00
A15WHT00
A18UND00
A60ASN00
A60BLK00
A60HSP00
A60NTV00
A60UP00
A60WHT00
A75UP00
AGEASN00
AGEBLK00
AGEHSP00
AGENTV00
AGEWHT00
ASIAN00
CHINA00
CUBAN00
FILIP00
HAW00
HISP00
HU00
INDIA00
JAPAN00
KOREA00
MEX00
NHBLK00
NHWHT00
NTV00
OHU00
OWN00
POP00
PR00
RENT00
VAC00
VIET00
time_period <- c("1980")

filter_time( dd, time_period) %>% pander()
root category definition 1980
state id state state
county id county county
tract id census tract tract
trtid id census tract (10 digit identifier) TRTID10
cbsa tract attribute A core-based statistical area (CBSA) is a U.S. geographic area defined by the Office of Management and Budget (OMB) that consists of one or more counties (or equivalents) anchored by an urban center of at least 10,000 people plus adjacent counties that are socioeconomically tied to the urban center by commuting cbsa10
ccflag tract attribute ccflag10
metdiv tract attribute Metropolitan Division metdiv10
placefp tract attribute 5-character place FIPS code placefp10
globd tract attribute GlobD80
globg tract attribute GlobG80
placefp tract attribute 5-character place FIPS code placefp10
cbsa tract attribute A core-based statistical area (CBSA) is a U.S. geographic area defined by the Office of Management and Budget (OMB) that consists of one or more counties (or equivalents) anchored by an urban center of at least 10,000 people plus adjacent counties that are socioeconomically tied to the urban center by commuting cbsa10
metdiv tract attribute Metropolitan Division metdiv10
ccflag tract attribute ccflag10
a18und age persons age 17 years and under A18UND80
a60up age persons age 60 years and over A60UP80
a75up age persons age 75 years and over A75UP80
ag15up age population 15 years and over (in 1970, population 14 years and over) AG15UP80
asian race persons of Asian race (and Pacific Islander) ASIAN80
china ethnicity persons of Chinese race CHINA80
cuban ethnicity Cubans CUBAN80
filip ethnicity persons of Filipino race FILIP80
haw race persons of Hawaiian race HAW80
hisp race persons of Hispanic origin HISP80
hu housing housing units HU80
india race persons of Asian Indian race INDIA80
japan ethnicity persons of Japanese race JAPAN80
korea ethnicity persons of Korean race KOREA80
mar marital currently married (excluding separated) Mar-80
mex ethnicity Mexicans MEX80
mhmval ses Median home value MHMVAL80
mrent ses Median monthly contract rent MRENT80
nhblk race persons of black race, not Hispanic origin NHBLK80
nhwht race persons of white race, not Hispanic origin NHWHT80
ntv race persons of Native American race NTV80
ohu housing occupied housing units OHU80
own housing owner-occupied housing units OWN80
pop demographics total population POP80
pr ethnicity Puerto Ricans PR80
rent housing renter-occupied housing units RENT80
vac housing vacant housing units VAC80
viet ethnicity persons of Vietnamese race VIET80
wds marital widowed, divorced, and separated WDS80

Code in this chapter was adapted from lab designs by Dr. Jesse Lecy and Professors Courtney Stowers and Christian Nuno at Arizona State University.