KIA

The following are steps undertaken for deidentifying NDMA data. This dataset covers 2020 through to June 2024 for KIA.

# Load required libraries
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.2
library(geosphere)
## Warning: package 'geosphere' was built under R version 4.3.3
## The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
## which was just loaded, will retire in October 2023.
## Please refer to R-spatial evolution reports for details, especially
## https://r-spatial.org/r/2023/05/15/evolution4.html.
## It may be desirable to make the sf package available;
## package maintainers should consider adding sf to Suggests:.
## The sp package is now running under evolution status 2
##      (status 2 uses the sf package in place of rgdal)
library(openxlsx)
## Warning: package 'openxlsx' was built under R version 4.3.3
file_path <- "C:/Users/AAH USER/Downloads/02_KIA_NDMA_2020 to June 2024.xlsx"

# Read the specific HHA sheet into a data frame
kia_2020_2024 <- read.xlsx(file_path, sheet = "KIA")

The dataset contains coordinates, however these are not household coordinates so we do not need to mask them. We ensure the Interview date column is parsed correctly as a date before saving the worksheet to the new workbook.

# Ensure the column is numeric
kia_2020_2024$InterviewDate <- as.numeric(kia_2020_2024$InterviewDate)

# Convert the numeric date to Date format
kia_2020_2024$InterviewDate <- as.Date(kia_2020_2024$InterviewDate, origin = "1899-12-30")

# View the first few dates to verify the conversion
head(kia_2020_2024$InterviewDate)
## [1] "2020-01-07" "2020-01-08" "2020-01-11" "2020-01-09" "2020-01-12"
## [6] "2020-01-14"

We save the sheet to a new workbook for the deidentified data for KIA 2020_June 2024.

# Define the path for the new workbook
new_file_path <- "C:/Users/AAH USER/OneDrive - Action Against Hunger USA/Documents/NDMA_DeIdentified/KIA_2020_June 2024.xlsx"

# Create a new workbook
wb <- createWorkbook()

# Add the HHA data to the new workbook
addWorksheet(wb, "KIA")
writeData(wb, "KIA", kia_2020_2024)

# Save the new workbook
saveWorkbook(wb, new_file_path, overwrite = TRUE)