-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentity_matching_census_acfrs.Rmd
65 lines (46 loc) · 1.5 KB
/
entity_matching_census_acfrs.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: "Census Entities vs. ACFRS Entities"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(tidyverse)
```
### ACFRS unique entities
```{r}
acfr_entity <- rio::import(here::here("data", "CAFRdata_20220111_221828.xlsx")) %>%
filter(Category != "Non-Profit") %>%
select(Entity) %>%
unique() %>%
mutate_all(tolower)
str(acfr_entity)
acfr_entity
str_replace(acfr_entity$Entity[100], "a", "A")
#remove "state of" in acfr entity
acfr_entity_rmStateof <- str_replace(acfr_entity$Entity, "state of", "")
str_detect(acfr_entity_rmStateof, "state of")
```
### Census Debt By Entity
```{r}
#data Marc emailed Jan 12
census_debt_entity <- rio::import(here::here("data", "Census Debt By Entity 2019.xlsx")) %>%
filter(`TOTAL DEBT (000s)` >= 500000) %>%
rename("State" = STATE) %>% select(ENTITY) %>%
mutate_all(tolower)
#CALIFORNIA in the Census Data is equivalent to State of California in ACFR data.
census_debt_entity %>% str()
```
### Census entities that are not included in ACFRS
```{r}
census_debt_entity %>%
filter(!ENTITY %in% acfr_entity$Entity) -> census_entities_NOT_in_acfrs
census_debt_entity %>%
filter(!ENTITY %in% acfr_entity_rmStateof)
census_entities_NOT_in_acfrs %>% str()
#write_csv(census_entities_NOT_in_acfrs, "census_entities_NOT_in_acfrs.csv")
```
### ACFRS entities that are not included in Census
```{r}
acfr_entity %>%
filter(!Entity %in% census_debt_entity$ENTITY) %>% str()
```