View source: R/ReformatLoops.R
gender_control_props | R Documentation |
Finds the gender control score for a single category (e.g. "male_adult"). See example
gender_control_props(genderdf, numberControllingDF, category)
genderdf |
A data frame of gender control strings in the wide format |
numberControllingDF |
A dataframe indicating the proportion of a resource to be divided up between household members |
category |
Which category we want to use to calculate the gender control scores (e.g. "male_adult") |
Rpackage file: ReformatLoops.R
# A dataset in the conventional RHoMIS format
data <- tibble::as_tibble(list(
crop_name_1 = c("banana", "cassava", NA, "millet"),
crop_name_2 = c("cassava", NA, "melon", "maize"),
random_crop_name_2 = c("blue", "green", "red", NA),
crop_name = c("orange", "purple", NA, "black"),
crop_control_1 = c(
"male_adult female_adult",
"male_adult",
NA,
"female_youth"
),
crop_control_2 = c("male_youth", NA, "female_youth", "female_adult")
))
# Converting the dataset to the wide format
# (i.e crops as header, and genders controlling for each crop)
wide_data <- map_to_wide_format(
data,
"crop_name",
c("crop_control"),
c("chr")
)
genderdf <- wide_data$crop_control
numberControllingDF <- genderdf %>%
dplyr::mutate(across(
.cols = everything(),
~ proportion_control_per_person(.x)
))
category <- "male_adult"
gender_control_props(genderdf, numberControllingDF, category)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.