Skip to content

Commit ec51ada

Browse files
committed
cleaning
1 parent 1967ce6 commit ec51ada

20 files changed

+60162
-4016
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
.Rhistory
33
.RData
44
.Ruserdata
5-
data
65
querydata_from_postgresQL.Rmd

acfrs_nces_school_discts.csv

-334
This file was deleted.

census_100k_not_acfrs.csv

-71
This file was deleted.

comparing_census_acfrs.csv

-55
This file was deleted.

comparing_census.Rmd comparing_census_national_state_debt.Rmd

+29-26
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
---
2-
title: "Comparing ACFRS data with Census Data"
3-
output:
2+
title: "Data Summary Statistics"
3+
date: June 11, 2022
4+
output:
45
html_document:
56
toc: true
67
toc_float: true
7-
toc_depth: 2
8+
toc_depth: 3
89
---
910

1011
```{r setup, include=FALSE}
1112
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
1213
library(tidyverse)
14+
library(dplyr)
15+
library(purrr)
16+
library(kableExtra)
17+
options(scipen=999)
1318
```
1419

15-
## Read in ACFRS data
20+
21+
##ACFRS Data
22+
Data was downloaded from website on Jan 11. Filtered out "Non-profit" category
23+
1624
```{r}
1725
options(scipen=999)
1826
jan11_site <- rio::import(here::here("data", "CAFRdata_20220111_221828.xlsx"))
@@ -21,19 +29,17 @@ jan11_site %>%
2129
select(State, Entity, Category,
2230
`Net Pension Liability`, `Net OPEB Assets`, `Net OPEB Liability`, `Bonds Outstanding`, `Notes Outstanding`,
2331
Leases, `Loans Outstanding`, `Compensated Absences`, `Total Liabilities`, Revenues) -> d
32+
head(d)
2433
25-
d %>% head()
2634
```
2735

28-
29-
## Read in census data
30-
36+
## Compare with Census Data
3137
The Census Bureau has national and state debt totals here:
3238
https://www2.census.gov/programs-surveys/gov-finances/tables/2019/19slsstab1a.xlsx
3339
and here:
3440
https://www2.census.gov/programs-surveys/gov-finances/tables/2019/19slsstab1b.xlsx.
3541

36-
The excel files have 5 components for each state. The column used below is "state & local government amount"
42+
The excel files has 5 components for each state. The column used below is "state & local government amount"
3743

3844
```{r}
3945
# first half
@@ -60,15 +66,18 @@ filter(`...1` == "125") %>%
6066
# joining
6167
state_local_amount_census <- rbind(state_local_amount1, state_local_amount2)
6268
69+
state_local_amount_census
6370
6471
```
65-
Census Debt Outstanding
6672

73+
Getting state.abb column
6774
```{r}
68-
#Getting state.abb column to join with acfrs data later
75+
76+
left_join(state_local_amount_census, state_abb)
6977
state_name_abb <- data.frame(state.abb, state.name) %>%
7078
rename("Name" = state.name)
71-
dc <- c("DC", "District of Columbia") # state.abb in R does not have DC
79+
80+
dc <- c("DC", "District of Columbia")
7281
7382
rbind(dc, state_name_abb) %>%
7483
arrange(Name) -> foo1
@@ -80,11 +89,9 @@ state_local_amount_census %>%
8089
8190
debt_outstanding_census <- cbind(foo1, foo2) %>% select(-State) %>%
8291
rename("State" = state.abb)
83-
84-
debt_outstanding_census
8592
```
8693

87-
## Compute sum of `Bonds Outstanding`, `Notes Outstanding`, Leases by state
94+
Compute sum of `Bonds Outstanding`, `Notes Outstanding`, `Leases` by state
8895

8996
```{r}
9097
d %>%
@@ -97,18 +104,14 @@ d %>%
97104
acfrs_debt
98105
```
99106

100-
Joining & Comparing census and ACFRS data
101-
102107
```{r}
103108
acfrs_debt %>%
104-
left_join(debt_outstanding_census) -> comparing_census_acfrs
105-
comparing_census_acfrs
106-
#write_csv(comparing_census_acfrs, "comparing_census_acfrs.csv")
107-
```
108-
109-
110-
111-
112-
109+
left_join(debt_outstanding_census) %>%
110+
mutate(ratio = state_sum_bonds_notes_leases - debt_outstanding_census)
113111
112+
debt_outstanding_census %>%
113+
as_tibble() %>%
114+
as.double(debt_outstanding_census)
115+
map_dbl(sum)
116+
```
114117

0 commit comments

Comments
 (0)