Skip to content

Commit

Permalink
TY 2022 data about taxable value per major property class (#18)
Browse files Browse the repository at this point in the history
* Initial commit

* Complete first draft

* Update renv lock

* Add additional major class sheet to output

* Code cleanup

* Commenting
  • Loading branch information
wrridgeway authored Feb 5, 2024
1 parent 76b89fd commit 97a4568
Show file tree
Hide file tree
Showing 5 changed files with 514 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
*.Rda
*.parquet
**/renv/activate.R
*.db
50 changes: 50 additions & 0 deletions data-requests/pdr-issue-0017/pdr-issue-0017.R
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")
16 changes: 16 additions & 0 deletions data-requests/pdr-issue-0017/pdr-issue-0017.Rproj
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
Loading

0 comments on commit 97a4568

Please sign in to comment.