Last updated: 2025-03-07

Checks: 5 2

Knit directory: QUAIL-Mex/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20241009) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.

absolute relative
/Users/palomacz/Documents/GitHub/QUAIL-Mex/data/Cleaned_Dataset_Screening_HWISE_PSS_V3.csv data/Cleaned_Dataset_Screening_HWISE_PSS_V3.csv

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 4c407eb. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    analysis/.RData
    Ignored:    analysis/.Rhistory
    Ignored:    code/.DS_Store
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  Cleaned_Dataset_Screening_HWISE_PSS_V2.csv
    Untracked:  analysis/Cleaned_Dataset_Screening_HWISE_PSS_V2.csv
    Untracked:  data/Filtered_Screening.csv

Unstaged changes:
    Modified:   analysis/HBA2025_Analyses.Rmd
    Modified:   analysis/HBA2025_cleaning.Rmd
    Modified:   analysis/MX28_plots.Rmd
    Modified:   analysis/Regression-Analysis_PC.Rmd
    Modified:   data/Cleaned_Dataset_Screening_HWISE_PSS_V3.csv

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/HBA2025_Analyses.Rmd) and HTML (docs/HBA2025_Analyses.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 3704a5a Paloma 2025-03-04 add more vars
html 3704a5a Paloma 2025-03-04 add more vars

Introduction

Here you will find the code used to obtain results shown in the annual meeting of the HBA, 2025.

Abstract:

Coping with water insecurity: women’s strategies and emotional responses in Iztapalapa, Mexico City

Water insecurity in urban areas presents distinctive challenges, particularly in marginalized communities. While past studies have documented how households adapt to poor water services, many of these coping strategies come at a significant personal cost. Here we examine the coping strategies and emotional impacts of unreliable water services among 400 women in Iztapalapa, Mexico City. Data were collected through surveys over the Fall of 2022 and Spring of 2023. We assessed household water access, water management practices, and emotional responses to local water services.

Results indicate that during acute water shortages, women can spend extended periods (several hours, or sometimes days) waiting for water trucks. Additionally, 57% of respondents reported feeling frustrated or angry about their water situation, while around 20% experienced family conflicts over water use or community-level conflicts around water management, often involving water vendors or government services.

This study offers one of the first in-depth examinations of how water insecurity specifically affects women in Iztapalapa, a densely populated region of Mexico City with severe water access challenges. The findings highlight the urgent need for policy interventions that address water insecurity with a gender-sensitive approach, recognizing the disproportionate burden placed on women as primary water managers in their households.

# Ensure HW_TOTAL is numeric
data$HW_TOTAL <- as.numeric(data$HW_TOTAL)

# Categorize HW_TOTAL into four groups
data <- data %>%
  mutate(HW_TOTAL_category = case_when(
    HW_TOTAL >= 0 & HW_TOTAL <= 2  ~ "No-to-Marginal",
    HW_TOTAL >= 3 & HW_TOTAL <= 11 ~ "Low",
    HW_TOTAL >= 12 & HW_TOTAL <= 23 ~ "Moderate",
    HW_TOTAL >= 24 & HW_TOTAL <= 36 ~ "High",
    TRUE ~ NA_character_  # Assign NA if value is missing or out of range
  ))

# Convert to factor to maintain categorical order
data$HW_TOTAL_category <- factor(data$HW_TOTAL_category, 
                                 levels = c("No-to-Marginal", "Low", "Moderate", "High"))

# HWISE scores 
summary(data$HW_TOTAL)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
  0.000   3.000   8.000   8.419  12.000  27.000      11 
# Check the new variable distribution
table(data$HW_TOTAL_category)

No-to-Marginal            Low       Moderate           High 
            76            205            104              6 

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
  0.000   5.000   9.000   9.715  14.000  27.000       6 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
  0.000   2.000   6.000   7.157  11.000  27.000       8 

No-to-Marginal            Low       Moderate           High 
            25            104             60              4 

No-to-Marginal            Low       Moderate           High 
            51            101             44              2 

Rainy season to dry season

data <- read.csv("/Users/palomacz/Documents/GitHub/QUAIL-Mex/data/Cleaned_Dataset_Screening_HWISE_PSS_V3.csv")

# Define Rainy (Fall = 1) and Dry (Spring = 0) seasons
data <- data %>%
  mutate(Season_Type = case_when(
    SEASON == 1 ~ "Rainy",
    SEASON == 0 ~ "Dry"
  ))

# Convert Season_Type to a factor
data$Season_Type <- factor(data$Season_Type, levels = c("Rainy", "Dry"))

# Categorize HW_TOTAL into four groups
data <- data %>%
  filter(!is.na(HW_TOTAL)) %>%  # Remove missing values
  mutate(HW_TOTAL_category = case_when(
    HW_TOTAL >= 0 & HW_TOTAL <= 2  ~ "No-to-Marginal",
    HW_TOTAL >= 3 & HW_TOTAL <= 11 ~ "Low",
    HW_TOTAL >= 12 & HW_TOTAL <= 23 ~ "Moderate",
    HW_TOTAL >= 24 & HW_TOTAL <= 36 ~ "High"
  ))

# Convert to factor with correct ordering
data$HW_TOTAL_category <- factor(data$HW_TOTAL_category, 
                                 levels = c("No-to-Marginal", "Low", "Moderate", "High"))

# Calculate the percentage for each category within each season
hw_season_counts <- data %>%
  filter(!is.na(HW_TOTAL_category)) %>%  # Ensure no NA categories
  group_by(Season_Type, HW_TOTAL_category) %>%
  summarise(Count = n(), .groups = 'drop') %>%
  group_by(Season_Type) %>%
  mutate(Percentage = (Count / sum(Count)) * 100)

# Reshape data to calculate the percentage difference (Dry - Rainy)
hw_diff <- hw_season_counts %>%
  select(Season_Type, HW_TOTAL_category, Percentage) %>%
  spread(Season_Type, Percentage) %>%  # Convert to wide format
  mutate(Difference = Dry - Rainy)  # Compute difference from Rainy to Dry

# Create the bar plot showing the percentage difference
ggplot(hw_diff, aes(x = HW_TOTAL_category, y = Difference, fill = Difference > 0)) +
  geom_bar(stat = "identity") +  # Use precomputed differences
  theme_minimal() +
  labs(title = "Change in HW_TOTAL Category Percentages (Rainy to Dry Season)",
       x = "HW_TOTAL Category", 
       y = "Percentage Difference (Rainy to Dry season)") +
  scale_fill_manual(values = c("#1f78b4", "#ff7f00"), labels = c("Decrease", "Increase")) +  # Assign colors
  theme(legend.position = "right") +  # Keep legend
  geom_text(aes(label = paste0(round(Difference, 1), "%")), vjust = -0.5)  # Add percentage labels

Version Author Date
3704a5a Paloma 2025-03-04

BOXPLOTS

data <- read.csv("./data/Cleaned_Dataset_Screening_HWISE_PSS_V3.csv")

# Categorize HW_TOTAL into four groups
data <- data %>%
  filter(!is.na(HW_TOTAL)) %>%  # Remove missing values
  mutate(HW_TOTAL_category = case_when(
    HW_TOTAL >= 0 & HW_TOTAL <= 2  ~ "No-to-Marginal",
    HW_TOTAL >= 3 & HW_TOTAL <= 11 ~ "Low",
    HW_TOTAL >= 12 & HW_TOTAL <= 23 ~ "Moderate",
    HW_TOTAL >= 24 & HW_TOTAL <= 36 ~ "High"
  ))

# Convert to factor with proper order
data$HW_TOTAL_category <- factor(data$HW_TOTAL_category, 
                                 levels = c("No-to-Marginal", "Low", "Moderate", "High"))

# Count the number of data points per HW_TOTAL category
category_counts <- data %>%
  group_by(HW_TOTAL_category) %>%
  summarise(Count = n(), .groups = 'drop')

# Define color palette
color_palette <- c("#1f78b4", "#a6cee3", "#fdbf6f", "#ff7f00")

# Create box-and-whisker plot with individual data points
ggplot(data, aes(x = HW_TOTAL_category, y = HRS_WEEK, fill = HW_TOTAL_category)) +
    geom_jitter(aes(color = HW_TOTAL_category), size = 1, width = 0.25) +  
  # Jitter adds individual data points
  geom_boxplot(outlier.shape = 1, alpha = 0.6, width = 0.4) +  # Boxplot without displaying outliers separately
 # geom_violin(alpha = 0.6, width = 1.4) +  # Boxplot without displaying outliers separately +
  theme_minimal() +
  labs(title = "Box-and-Whisker Plot: HRS_WEEK by HWISE Category",
       x = "HWISE", 
       y = "Hours of Water Supply per Week") +
  scale_fill_manual(values = color_palette) +  # Custom colors for boxes
  scale_color_manual(values = color_palette) +  # Custom colors for points
  theme(legend.position = "none") + # Remove legend for clarity 
scale_x_discrete(labels = paste0(category_counts$HW_TOTAL_category, " (n=", category_counts$Count, ")"))  # Add count to x-axis labels
Warning: Removed 37 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 37 rows containing missing values or values outside the scale range
(`geom_point()`).

Version Author Date
3704a5a Paloma 2025-03-04

sessionInfo()
R version 4.4.3 (2025-02-28)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.3.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Detroit
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] knitr_1.49     reshape2_1.4.4 tidyr_1.3.1    ggplot2_3.5.1  dplyr_1.1.4   

loaded via a namespace (and not attached):
 [1] gtable_0.3.6      jsonlite_1.8.9    compiler_4.4.3    promises_1.3.0   
 [5] tidyselect_1.2.1  Rcpp_1.0.13-1     stringr_1.5.1     git2r_0.35.0     
 [9] later_1.3.2       jquerylib_0.1.4   scales_1.3.0      yaml_2.3.10      
[13] fastmap_1.2.0     plyr_1.8.9        R6_2.5.1          labeling_0.4.3   
[17] generics_0.1.3    workflowr_1.7.1   tibble_3.2.1      munsell_0.5.1    
[21] rprojroot_2.0.4   bslib_0.8.0       pillar_1.9.0      rlang_1.1.4      
[25] utf8_1.2.4        cachem_1.1.0      stringi_1.8.4     httpuv_1.6.15    
[29] xfun_0.49         fs_1.6.5          sass_0.4.9        cli_3.6.3        
[33] withr_3.0.2       magrittr_2.0.3    grid_4.4.3        digest_0.6.37    
[37] rstudioapi_0.17.1 lifecycle_1.0.4   vctrs_0.6.5       evaluate_1.0.1   
[41] glue_1.8.0        farver_2.1.2      whisker_0.4.1     colorspace_2.1-1 
[45] fansi_1.0.6       purrr_1.0.2       rmarkdown_2.29    tools_4.4.3      
[49] pkgconfig_2.0.3   htmltools_0.5.8.1