Skip to content

Commit

Permalink
added Kyiv as an artificial hromada
Browse files Browse the repository at this point in the history
  • Loading branch information
andkov committed Aug 21, 2022
1 parent 4914d50 commit 934dfd0
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 21 deletions.
3 changes: 2 additions & 1 deletion manipulation/ellis-economics.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ ds2_basic <-
select(!starts_with("settlement")) %>%
distinct()
, by = "hromada_code"
)
) %>%
arrange(desc(hromada_code))
ds2_basic %>% glimpse(70)

# ds1 %>%
Expand Down
43 changes: 35 additions & 8 deletions manipulation/ellis-rada-hromada.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ ds1_rada <-
ds0_rada %>%
select(
rada_code, rada_name, hromada_code, hromada_name, rai_center, oblast, note
)
) %>%
arrange(desc(hromada_code))
ds1_rada %>% glimpse(80)
# ds1_rada %>% filter(rada_code == "8000000000")
# ds1_rada %>% filter(hromada_code == "UA80")

names(ds0_hromada) <- names_hromada
# ds0_hromada <- ds0_hromada %>% filter(!hromada_code == "#N/A") # Kyiv
Expand All @@ -184,6 +188,23 @@ missing_radas <-

missing_radas %>% neat_DT()

# manualy adjust for Kyiv
# Maybe: change it in the source data?

ds0_hromada %>% glimpse()

ds0_hromada %>%
filter(main_rada_code %in% c("8000000000","8500000000")) %>% t()

# ds0_hromada <-
# ds0_hromada %>%
# mutate(
# hromada_code = case_when(
# main_rada_code == "8000000000" ~ "UA8"
# ,TRUE ~ hromada_code
# )
# )

# create a ds listing the final list of hromadas along with the founding radas
ds1_hromada <-
ds0_hromada %>%
Expand All @@ -195,9 +216,12 @@ ds1_hromada <-
,main_rada_code
,rada_codes_final
) %>%
arrange(hromada_code)
arrange(desc(hromada_code))
ds1_hromada

ds0_hromada %>% glimpse(60)
ds1_hromada %>% glimpse(60)

# create a ds listing the dates on which hromadas changed their composition
ds0_time <-
ds0_hromada %>%
Expand Down Expand Up @@ -228,20 +252,23 @@ ds1_time <-
# ,rada_code = as.integer(rada_code)
) %>%
filter(!is.na(rada_code)) %>%
arrange(hromada_code, date, rada_code) %>%
arrange(desc(hromada_code), date, rada_code) %>%
select(date,rada_code, hromada_code) %>%
print()

# ds1_time %>% filter(hromada_code=="UA8")
#+ inspect-data-2 ----------------------------------------------------------------
ds1_time %>% glimpse() # date when rada joins a hromada / when hromada alters its composition
ds1_rada %>% glimpse() # mapping of radas to hromadas at the end of amalgamation
ds1_hromada %>% glimpse() # the final list of hromadas at the end of amalgamation proces
ds_admin %>% glimpse() # supporing meta-data file with admin level mapping
ds1_time %>% glimpse(80) # date when rada joins a hromada / when hromada alters its composition
ds1_rada %>% glimpse(80) # mapping of radas to hromadas at the end of amalgamation
ds1_hromada %>% glimpse(80) # the final list of hromadas at the end of amalgamation proces
ds_admin %>% glimpse(80) # supporing meta-data file with admin level mapping



#+ table-1 ---------------------------------------------------------------------

ds1_time %>%
left_join(ds_admin %>% distinct(hromada_code, hromada_name)) %>%
arrange(desc(hromada_code))

#+ graph-1 ---------------------------------------------------------------------
#+ graph-2 ---------------------------------------------------------------------
Expand Down
44 changes: 32 additions & 12 deletions manipulation/ellis-ua-admin.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ ds0 <- readr::read_csv(path_raw, col_names = names_admin_ua, skip=1)
ds0_oblast <- readr::read_csv(path_oblasti, skip=0)

#+ inspect-data ----------------------------------------------------------------
ds0 %>% glimpse()
ds0 %>% glimpse(80)

ds0 %>% count(object_category)

#+ tweak-data, eval=eval_chunks ------------------------------------------------

ds1 <-
ds0 %>%
mutate(
Expand All @@ -83,16 +82,17 @@ ds1 <-
)
ds1 %>% group_by(object_category, category_label) %>% tally()

ds1 %>% glimpse()
ds1 %>% glimpse(80)
ds1 %>% filter(object_category == "K")

#+ table-1 ---------------------------------------------------------------------

ds_oblast <-
ds1 %>%
filter(object_category == "O") %>%
filter(object_category %in% c("O","K")) %>%
distinct(oblast_code = level_1, oblast_name = object_name)

ds_oblast
ds_oblast %>% print_all()

ds_raion <-
ds1 %>%
Expand All @@ -102,15 +102,25 @@ ds_raion

ds_hromada <-
ds1 %>%
filter(object_category == "H") %>%
distinct(hromada_code = level_3, hromada_name = object_name)
filter(object_category %in% c("H","K") ) %>%
distinct(hromada_code = level_3, hromada_name = object_name) %>%
# bind_rows(
# tibble::tribble(
# ~hromada_code, ~hromada_name,
# "UA80", "м.Київ",
# "UA85", "м.Севастопіль"
# )
# ) %>%
arrange(desc(hromada_code))

ds_hromada

ds_settlement <-
ds1 %>%
filter(object_category %in% c("X","C","T","M") ) %>%
filter(object_category %in% c("X","C","T","M","K") ) %>%
distinct(settlement_code = level_4, settlement_name = object_name,
settlement_type = category_label)
settlement_type = category_label) %>%
arrange(desc(settlement_code))
ds_settlement


Expand All @@ -136,7 +146,8 @@ ds_map_hromada <-
,by = "oblast_code"
)
ds_map_hromada

ds_map_hromada %>% glimpse(80)
ds_map_hromada %>% filter(hromada_code %in% c("UA80", "UA85")) %>% t()

ds_map_settlement <-
#1
Expand All @@ -154,10 +165,12 @@ ds_map_settlement

# demonstrate that ds_map_hromada can be devided from ds_map_settlement
identical(
ds_map_hromada
ds_map_hromada %>%
arrange(hromada_code)
,ds_map_settlement %>%
select(!starts_with("settlement_")) %>%
distinct()
distinct() %>%
arrange(hromada_code)
)
# Therefore we will use ds_map_settlement as the primary file
# last touch: adding oblast-level helpers
Expand All @@ -170,6 +183,13 @@ ds_admin <-
,oblast_name_display = fct_reorder(oblast_name_display, map_position)
)
ds_admin %>% glimpse(90)

ds_admin %>% arrange(desc(hromada_code)) %>% glimpse(80)

# ds_admin %>%
# filter(hromada_code %in% c("UA80","UA85")) %>%
# View()

#+ graph-1 ---------------------------------------------------------------------
#+ graph-2 ---------------------------------------------------------------------
#+ save-to-disk, eval=eval_chunks-----------------------------------------------
Expand Down

0 comments on commit 934dfd0

Please sign in to comment.