# budget <- read_parquet("data-processed/budgets_druhove_annual.parquet")
budget <- read_parquet("data-input/budgets_income_bare.parquet")
source("shared.R")
## ℹ Codelist file already in 'data-input/sp/', not downloading. Set `redownload = TRUE` if needed.
## ℹ Processing codelist data
## ℹ Codelist file already in 'data-input/sp/', not downloading. Set `redownload = TRUE` if needed.
## ℹ Processing codelist data
obce_income_endyear_polozka_cons <- budget %>%
filter(ico %in% ico_obce & per_m == "12") %>%
# filter to keep only income
sp_add_codelist(polozka) %>%
# konsolidovat na urovni ucetni jednotky
filter(!kon_pol)
RUD
b_rud <- obce_income_endyear_polozka_cons %>%
mutate(rud = polozka %in% polozky_rud) %>%
group_by(ico, rud, period_vykaz, per_yr) %>%
summarise_at(vars(starts_with("budget_")), sum, na.rm = T) %>%
group_by(ico, period_vykaz, per_yr) %>%
mutate(podil_rud = budget_spending/sum(budget_spending)) %>%
filter(rud) %>%
sp_add_codelist(orgs) %>%
select(-kraj) %>%
sp_add_codelist("nuts", dest_dir = "data-input") %>%
left_join(katobyv) %>%
mutate(katobyv_nazev = as.factor(katobyv_nazev) %>%
fct_reorder(as.integer(katobyv_id)),
rok = as.numeric(per_yr)) %>%
filter(TRUE)
## ℹ Building URL for codelist 'nuts' - Klasifikace územních statistických jednotek NUTS
## ✓ Storing codelist in 'data-input/'
## ℹ Processing codelist data
## Joining, by = "katobyv_id"
b_rud_summary <- obce_income_endyear_polozka_cons %>%
mutate(rud = polozka %in% polozky_rud) %>%
group_by(rud, period_vykaz, per_yr) %>%
summarise_at(vars(starts_with("budget_")), sum, na.rm = T) %>%
group_by(period_vykaz, per_yr) %>%
mutate(podil_rud = budget_spending/sum(budget_spending)) %>%
filter(rud) %>%
filter(TRUE)
b_rud_summary
b_rud %>%
filter(podil_rud > 0 & per_yr == 2019) %>%
ggplot(aes(per_yr, podil_rud)) +
geom_boxplot(alpha = .1) +
# facet_wrap(~ katobyv_nazev) +
theme_ptrr("both", multiplot = T) +
scale_y_percent_cz(limits = c(0, 1)) +
scale_x_discrete(breaks = c(2010, 2013, 2016, 2019))
Daň z nemovitosti
b_dzn <- obce_income_endyear_polozka_cons %>%
mutate(rud = polozka %in% polozky_dzn) %>%
group_by(ico, rud, period_vykaz, per_yr) %>%
summarise_at(vars(starts_with("budget_")), sum, na.rm = T) %>%
group_by(ico, period_vykaz, per_yr) %>%
mutate(podil_rud = budget_spending/sum(budget_spending)) %>%
filter(rud) %>%
sp_add_codelist(orgs) %>%
select(-kraj) %>%
sp_add_codelist("nuts", dest_dir = "data-input") %>%
left_join(katobyv) %>%
mutate(katobyv_nazev = as.factor(katobyv_nazev) %>%
fct_reorder(as.integer(katobyv_id)),
rok = as.numeric(per_yr)) %>%
filter(TRUE)
## ℹ Codelist file already in 'data-input/', not downloading. Set `redownload = TRUE` if needed.
## ℹ Processing codelist data
## Joining, by = "katobyv_id"
b_dzn %>%
filter(podil_rud > 0) %>%
ggplot(aes(per_yr, podil_rud)) +
geom_boxplot(alpha = .1) +
facet_wrap(~ katobyv_nazev) +
theme_ptrr("both", multiplot = T) +
scale_y_percent_cz(limits = c(0, 1)) +
scale_x_discrete(breaks = c(2010, 2013, 2016, 2019))