-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TY 2022 data about taxable value per major property class (#18)
* Initial commit * Complete first draft * Update renv lock * Add additional major class sheet to output * Code cleanup * Commenting
- Loading branch information
1 parent
76b89fd
commit 97a4568
Showing
5 changed files
with
514 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ | |
*.Rda | ||
*.parquet | ||
**/renv/activate.R | ||
*.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# See https://github.com/ccao-data/public/issues/17 | ||
|
||
library(dplyr) | ||
library(openxlsx) | ||
library(ptaxsim) | ||
library(purrr) | ||
|
||
# Create the DB connection with the default name expected by PTAXSIM functions | ||
ptaxsim_db_conn <- DBI::dbConnect(RSQLite::SQLite(), "ptaxsim/ptaxsim.db") | ||
|
||
# Gather a list of all '22 parcels | ||
eav22 <- DBI::dbGetQuery( | ||
ptaxsim_db_conn, | ||
" | ||
SELECT DISTINCT pin | ||
FROM pin | ||
WHERE year = 2022 | ||
" | ||
) %>% | ||
pull(pin) | ||
|
||
# Use tax_bill() to obtain EAVs for all '22 parcels, filter our rows that don't | ||
# pertain to a parcel's municipality. It's worth noting here that this sample | ||
# will NOT include all '22 parcels due to this filter - any parcels that don't | ||
# include a "muni" component in their tax bill will not show up in this output | ||
munis <- tax_bill(year_vec = 2022, pin_vec = eav22) %>% | ||
filter(agency_minor_type == "MUNI") %>% | ||
mutate("Major Class" = substr(class, 1, 1)) %>% | ||
rename("Minor Class" = class) | ||
|
||
# Aggregate by class and municipality, output | ||
c("Minor Class", "Major Class") %>% | ||
set_names() %>% | ||
map(function(x) { | ||
munis %>% | ||
summarise( | ||
num_pins = n(), | ||
median_eav = median(eav, na.rm = TRUE), | ||
total_eav = sum(eav, na.rm = TRUE), | ||
.by = c({{ x }}, agency_name) | ||
) %>% | ||
select( | ||
Municipality = agency_name, | ||
Class = {{ x }}, | ||
`Num Parcels` = num_pins, | ||
`Median EAV` = median_eav, | ||
`Total EAV` = total_eav | ||
) | ||
}) %>% | ||
write.xlsx("eavs22.xlsx") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes |
Oops, something went wrong.