type_comparison <- comparison=="type"
area_comparison <- comparison=="area"

df1 <- NULL
df2 <- NULL
df3 <- NULL
fig_df <- fig_df %>%
  merge(research_facilities,
        by.x = facility_col,
        by.y = 'facility_id',
        all.x = TRUE)
tmp <- fig_df %>%
  dplyr::group_by(!!rlang::sym(date_col),!!rlang::sym(facility_col)) %>%
  dplyr::count()
max_val = max(tmp$n)
df1 <- fig_df %>% dplyr::filter(type == "Dispensary")
df2 <- fig_df %>% dplyr::filter(type == "Health Center")
df1 <- fig_df %>% dplyr::filter(lvl2 == "Kakamega County")
df2 <- fig_df %>% dplyr::filter(lvl2 == "Kitui County")
df3 <- fig_df %>% dplyr::filter(lvl2 == "Uasin Gishu County")

lbl1 <- "Kakamega County"
lbl2 <- "Kitui County"
lbl3 <- "Uasin Gishu County"
df1 <- fig_df %>% dplyr::filter(lvl2 == "Kaliua")
df2 <- fig_df %>% dplyr::filter(lvl2 == "Sengerema")
df3 <- fig_df %>% dplyr::filter(lvl2 == "Tanga")
df1 <- fig_df %>% dplyr::filter(lvl2 == "Deoria")
df2 <- fig_df %>% dplyr::filter(lvl2 == "Sitapur")
df3 <- fig_df %>% dplyr::filter(lvl2 == "Unnao")
timci::plot_geom_bar_by_facility_over_time(df = df1,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 4,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df2,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 4,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df1,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 3,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df2,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 3,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df3,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 3,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df1,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 5,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df2,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 5,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df3,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 5,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df1,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 5,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df2,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 5,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = df3,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 5,
                                           text_size = tsize)
timci::plot_geom_bar_by_facility_over_time(df = fig_df,
                                           facility_col = facility_col,
                                           date_col = date_col,
                                           date_lbl = date_lbl,
                                           date_break_str = dbreak_duration,
                                           date_format = date_format,
                                           start_date = start_date,
                                           end_date = lock_date,
                                           max_val = max_val,
                                           fill_col = fill_col,
                                           n_facet_per_row = 5,
                                           text_size = tsize)
rm(df1,
   df2,
   df3)
gc()


Thaliehln/timci documentation built on April 8, 2024, 3:38 p.m.