Last updated: 2025-03-03

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.csv data/Cleaned_Dataset_Screening_HWISE_PSS.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 1b8f52e. 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:    analysis/.DS_Store
    Ignored:    analysis/.RData
    Ignored:    analysis/.Rhistory
    Ignored:    code/.DS_Store
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  temp.Rmd
    Untracked:  temp.html

Unstaged changes:
    Modified:   analysis/HBA2024_Analyses.Rmd

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/HBA2024_Analyses.Rmd) and HTML (docs/HBA2024_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 1b8f52e Paloma 2025-03-03 cleaning

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.

Number of individuals with HW_TOTAL > 12: 97 ( 24.25 %)
Number of individuals with HW_TOTAL > 8: 172 ( 43 %)

BOXPLOTS

# Create a categorical variable for HW_TOTAL threshold
df <- df %>%
  mutate(HW_Group = ifelse(HW_TOTAL > 8, "Above 8", "Below 8"))

# Identify numeric columns for plotting (excluding HW_TOTAL and ID)
numeric_columns <- df %>%
  select(where(is.numeric)) %>%
  select(-c(HW_TOTAL, ID)) %>%
  names()

# Create plots for all numeric variables
plot_list <- list()

for (var in numeric_columns) {
  p <- ggplot(df, aes(x = HW_Group, y = .data[[var]], fill = HW_Group)) +
    geom_boxplot(alpha = 0.7, outlier.shape = NA) +
    geom_jitter(width = 0.03, alpha = 0.35) +
    labs(title = paste("Comparison of", var, "by HWISE score group"),
         x = "HW Group",
         y = var) +
    theme_minimal() +
    theme(legend.position = "none")

  plot_list[[var]] <- p
  print(p)  # Print each plot
}
Warning: Removed 17 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 17 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 51 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 51 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 5 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 5 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 5 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 5 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 4 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

cat("Generated comparison plots for all numeric variables based on HW_TOTAL.\n")
Generated comparison plots for all numeric variables based on HW_TOTAL.

BARPLOTS

# ========================
# Visualizing Categorical Variables
# ========================

# Create bar plots for categorical variables by HW_Group
cat_plot_list <- list()

for (var in cat_columns) {
  p_cat <- ggplot(df, aes(x = .data[[var]], fill = HW_Group)) +
    geom_bar(position = "dodge") +
    labs(title = paste("Distribution of", var, "by HWISE score group"),
         x = var,
         y = "Count") +
    theme_minimal() +
    theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for readability

  cat_plot_list[[var]] <- p_cat
  print(p_cat)  # Print each plot
}

cat("Generated comparison plots for all categorical variables based on HW_TOTAL.\n")
Generated comparison plots for all categorical variables based on HW_TOTAL.
## Explore HWISE total scores

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

# Ensure categorical variables are factors
cat_columns <- grep("CAT$", names(df), value = TRUE)
df <- df %>%
  mutate(across(all_of(cat_columns), as.factor))

# Get total number of individuals
total_individuals <- nrow(df)

# Count individuals with HW_Total > 12 and HW_Total > 8
count_hw_above_12 <- df %>%
  filter(HW_TOTAL > 12) %>%
  summarise(count = n())

count_hw_above_8 <- df %>%
  filter(HW_TOTAL > 8) %>%
  summarise(count = n())

# Calculate percentages
percent_hw_above_12 <- (count_hw_above_12$count / total_individuals) * 100
percent_hw_above_8 <- (count_hw_above_8$count / total_individuals) * 100

# Print results
cat("Number of individuals with HW_Total > 12:", count_hw_above_12$count, 
    "(", round(percent_hw_above_12, 2), "%)\n")
Number of individuals with HW_Total > 12: 97 ( 24.25 %)
cat("Number of individuals with HW_Total > 8:", count_hw_above_8$count, 
    "(", round(percent_hw_above_8, 2), "%)\n")
Number of individuals with HW_Total > 8: 172 ( 43 %)
# Create a categorical variable for HW_Total threshold
df <- df %>%
  mutate(HW_Group = ifelse(HW_TOTAL > 8, "Above 8", "Below 8"))

"Identify numeric columns for plotting (excluding HW_Total and ID)"
[1] "Identify numeric columns for plotting (excluding HW_Total and ID)"
numeric_columns <- df %>%
  select(where(is.numeric)) %>%
  select(-c(HW_TOTAL, ID)) %>%
  names()

# Create plots for all numeric variables
plot_list <- list()

for (var in numeric_columns) {
  p <- ggplot(df, aes(x = HW_Group, y = .data[[var]], fill = HW_Group)) +
    geom_boxplot(alpha = 0.7, outlier.shape = NA) +
    geom_jitter(width = 0.1, alpha = 0.5) +
    labs(title = paste("Comparison of", var, "by HWISE score group"),
         x = "HW Group",
         y = var) +
    theme_minimal() +
    theme(legend.position = "none")

  plot_list[[var]] <- p
  print(p)  # Print each plot
}
Warning: Removed 17 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 17 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 51 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 51 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 5 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 5 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 5 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 5 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 4 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 3 rows containing non-finite outside the scale range
(`stat_boxplot()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

cat("Generated comparison plots for all numeric variables based on HW_Total.\n")
Generated comparison plots for all numeric variables based on HW_Total.
# Subset only numeric columns
df_numeric <- df %>% select(all_of(numeric_columns))

# Compute correlation matrix (excluding NAs)
cor_matrix <- cor(df_numeric, use = "pairwise.complete.obs")

# ========================
# Heatmap using ggplot2
# ========================

# Convert the correlation matrix into a format suitable for ggplot2
cor_data <- melt(cor_matrix)

# Create heatmap plot
ggplot(cor_data, aes(Var1, Var2, fill = value)) +
  geom_tile() +
  scale_fill_gradient2(low = "blue", high = "red", mid = "white", 
                       midpoint = 0, limit = c(-1,1), space = "Lab",
                       name="Correlation") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  labs(title = "Correlation Heatmap",
       x = "", y = "")


sessionInfo()
R version 4.4.2 (2024-10-31)
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] 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.2    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   knitr_1.49        tibble_3.2.1     
[21] munsell_0.5.1     rprojroot_2.0.4   bslib_0.8.0       pillar_1.9.0     
[25] rlang_1.1.4       utf8_1.2.4        cachem_1.1.0      stringi_1.8.4    
[29] httpuv_1.6.15     xfun_0.49         fs_1.6.5          sass_0.4.9       
[33] cli_3.6.3         withr_3.0.2       magrittr_2.0.3    grid_4.4.2       
[37] digest_0.6.37     rstudioapi_0.17.1 lifecycle_1.0.4   vctrs_0.6.5      
[41] evaluate_1.0.1    glue_1.8.0        farver_2.1.2      whisker_0.4.1    
[45] colorspace_2.1-1  fansi_1.0.6       purrr_1.0.2       rmarkdown_2.29   
[49] tools_4.4.2       pkgconfig_2.0.3   htmltools_0.5.8.1