diff --git a/R/HT_02_importDHS_hh.R b/R/HT_02_importDHS_hh.R index d182749..468e4a1 100644 --- a/R/HT_02_importDHS_hh.R +++ b/R/HT_02_importDHS_hh.R @@ -154,8 +154,8 @@ hh = hh %>% # Convert regions into urban-rural + region. hh = hh %>% - mutate(region_urban = case_when(hh$urban == 1 ~ paste0(hh$region_name, ' - urban'), - hh$urban == 0 ~ paste0(hh$region_name, ' - rural'), + mutate(region_urban = case_when(hh$urban == 1 ~ paste0(hh$region_name, '_and_urban'), + hh$urban == 0 ~ paste0(hh$region_name, '_and_rural'), TRUE ~ NA_character_)) # -- Checks that recoding doesn't change the # of values -- diff --git a/R/HT_05_improvedWater.R b/R/HT_05_improvedWater.R index 9fe6017..1fd8d76 100644 --- a/R/HT_05_improvedWater.R +++ b/R/HT_05_improvedWater.R @@ -160,7 +160,6 @@ plotMap(haiti_polygons, # For krigging, unnecessary to apply weights to each EA (since same) write_csv(hh, '~/Documents/USAID/Haiti/dataout/HT_DHS2012_imprsanitation_2016-08-29.csv') -x = calcPtEst('impr_water_dhs', by_var = 'region_urban', design = DHSdesign, df = hh) # Admin2 map -------------------------------------------------------------- @@ -184,4 +183,18 @@ pairGrid(water_admin2, colorDot = colour_water, savePlots = TRUE, fill_limits = colour_limits, - file_name = '~/Creative Cloud Files/MAV/Haiti_WASH-PAD_2016-09/exported_R/HTI_imprwater_adm2dot.pdf') \ No newline at end of file + file_name = '~/Creative Cloud Files/MAV/Haiti_WASH-PAD_2016-09/exported_R/HTI_imprwater_adm2dot.pdf') + + + +# urban/rural splot ------------------------------------------------------- + +urb_rural_imprwater = calcPtEst('impr_water_under30min', by_var = 'region_urban', design = DHSdesign, df = hh) + +urb_rural_imprwater = urb_rural_imprwater %>% + separate(region_urban, c('region', 'urban'), sep = '_and_') + + +ggplot(urb_rural_imprwater, aes(x = avg, y = region, + fill = avg, shape = urban)) + + geom_point(size = 4)