Credit Health during the COVID-19 Pandemic
This repo contains the code for the data tool Credit Health during the COVID-19 Pandemic. This tool allows users to find out how credit health has developed since February 2020 at a national, state, and county level. It also provides data on racial disparities in credit health.
How to update
Updates in the tool
With every new update, the tool will require changes in the index.html and scripts/main.js files. In both, there are comments that include the text UPDATE this.
Data inputs
The research team should provide three Excel files for national, state and county data. Each of those files include a tab for every month with available data. These files are not ready for publication.
Data processing
On the source folder, there are two R scripts: set-up.R and clean-data.R.
set-up.Rloads the packages used to clean the data. It's not necessary to run it.clean-data.Rtakes the three files shared by the research team and formats them for publication (set-up.Rruns within this script). This is how it works: Each tab in the excel files is collapsed into a single list of lists. The nested list is transformed into a data frame (DF). There's a little bit of cleaning (dollar symbol removed, readable date format, i.e.) and three new DFs are built and saved as csv files (us.csv,state.csv,county.csv). These three files feed the tool. Once created, move them to thedata/formattedfolder.
DISCLOSURE
- Original files built by the researchers might be named differently with every new update. Double-check the files' names and change, if necessary, in
clean-data.Rbefore running the code. set-up.Randclean-data.Rwere originally written to be run within an R project and using a folder structure with three folders:
data-in, it should include the original data sent by the research team.scripts, it should include theset-up.Randclean-data.R.data-out, it should include the three files generated byclean-data.R.
You can replicate that folder structure and create an R project –or use the here package instead. You can also rewrite the paths to make it work following whatever system you prefer.
What if an update includes new metrics
That will require to update dict.csv, hosted in the data folder. Basically, the file matches the names of variables in the datasets with the names used for each metric in the dropdown menu.
Hosting the staging version
For clarity and order, host the staging code inside the features/tpm/credit-health-updates folder. There, create a new folder YEAR/MONTH-update and clone the repo.