gender_control_props: Gender Control Props

View source: R/ReformatLoops.R

gender_control_propsR Documentation

Gender Control Props

Description

Finds the gender control score for a single category (e.g. "male_adult"). See example

Usage

gender_control_props(genderdf, numberControllingDF, category)

Arguments

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")

Details

Rpackage file: ReformatLoops.R

Examples


# 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)

l-gorman/rhomis-R-package documentation built on Nov. 8, 2023, 6:46 a.m.