From f4309950d06cb7be6589886cf49be851f78222e3 Mon Sep 17 00:00:00 2001 From: nicolefindstar Date: Thu, 1 Aug 2024 11:07:41 +0200 Subject: [PATCH 1/6] Updated Pro-CC-1-1, formatted SPSS and R, added Stata and Python --- Indicators/Protection-CRF-CC1-1/pro-CC-1-1.do | 21 +++++++++++++ Indicators/Protection-CRF-CC1-1/pro-CC-1-1.py | 31 +++++++++++++++++++ .../Protection-CRF-CC1-1/pro-CC-1-1.sps | 18 ++++++++--- .../pro-CC-1-1_tidyverse.R | 29 ++++++++++------- 4 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 Indicators/Protection-CRF-CC1-1/pro-CC-1-1.do create mode 100644 Indicators/Protection-CRF-CC1-1/pro-CC-1-1.py diff --git a/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.do b/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.do new file mode 100644 index 0000000..dca6f7a --- /dev/null +++ b/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.do @@ -0,0 +1,21 @@ +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Security Challenges Indicator +*------------------------------------------------------------------------------* + +* This script processes the security challenges indicator by assessing +* whether households have experienced any security challenge related to WFP assistance. + +* Define variable and value labels. +label variable HHAsstSecurity "Have you or any of your household members experienced any security challenge related to WFP assistance?" +label define HHAsstSecurity_lbl 0 "No" 1 "Yes" 888 "Don't know" +label values HHAsstSecurity HHAsstSecurity_lbl + +* Display frequency of HHAsstSecurity. +tabulate HHAsstSecurity + +* Create a table of the weighted percentage of HHAsstSecurity. +cap gen WeightHH = 1 +tabulate HHAsstSecurity [aw = WeightHH] + +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.py b/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.py new file mode 100644 index 0000000..937db21 --- /dev/null +++ b/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.py @@ -0,0 +1,31 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Security Challenges Indicator +#------------------------------------------------------------------------------# + +# This script processes the security challenges indicator by assessing +# whether households have experienced any security challenge related to WFP assistance. + +import pandas as pd +import numpy as np + +# Add sample data. +#data = pd.read_csv("~/GitHub/RAMResourcesScripts/Static/PROP_AAP_CRF_Sample_Survey.csv") + +# Assign variable and value labels. +data['HHAsstSecurity'] = data['HHAsstSecurity'].astype('category') +data['HHAsstSecurity'].cat.rename_categories({ + 0: 'No', + 1: 'Yes', + 888: 'Don\'t know' +}, inplace=True) + +# Create a table of the weighted percentage of HHAsstSecurity. +HHAsstSecurity_table = data['HHAsstSecurity'].value_counts(normalize=True).reset_index() +HHAsstSecurity_table.columns = ['HHAsstSecurity', 'Percentage'] +HHAsstSecurity_table['Percentage'] *= 100 + +# Print the table. +print(HHAsstSecurity_table) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.sps b/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.sps index 5dd1735..ce92f5c 100644 --- a/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.sps +++ b/Indicators/Protection-CRF-CC1-1/pro-CC-1-1.sps @@ -1,9 +1,17 @@ -* Encoding: UTF-8. +******************************************************************************** +* WFP Standardized Scripts +* Security Challenges Indicator +******************************************************************************** -* define variable and value labels +* This script processes the security challenges indicator by assessing +* whether households have experienced any security challenge related to WFP assistance. -Variable labels HHAsstSecurity ‘Have you or any of your household members experienced any security challenge related to WFP assistance?’. +* Define variable and value labels. -Value labels HHAsstSecurity 1 'Yes' 0 'No '. +VARIABLE LABELS HHAsstSecurity "Have you or any of your household members experienced any security challenge related to WFP assistance?". +VALUE LABELS HHAsstSecurity 1 'Yes' 0 'No' 888 'Don\'t know'. -freq HHAsstSecurity. +* Display frequency of HHAsstSecurity. +FREQUENCIES VARIABLES = HHAsstSecurity. + +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-1/pro-CC-1-1_tidyverse.R b/Indicators/Protection-CRF-CC1-1/pro-CC-1-1_tidyverse.R index fda7acf..1b23f4c 100644 --- a/Indicators/Protection-CRF-CC1-1/pro-CC-1-1_tidyverse.R +++ b/Indicators/Protection-CRF-CC1-1/pro-CC-1-1_tidyverse.R @@ -1,11 +1,19 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Security Challenges Indicator +#------------------------------------------------------------------------------# + +# This script processes the security challenges indicator by assessing +# whether households have experienced any security challenge related to WFP assistance. + library(tidyverse) library(expss) library(labelled) -#add sample data -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/PROP_AAP_CRF_Sample_Survey.csv") +# Add sample data. +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/PROP_AAP_CRF_Sample_Survey.csv") -#assign variable and value labels +# Assign variable and value labels. var_label(data$HHAsstSecurity) <- "Have you or any of your household members experienced any security challenge related to WFP assistance?" val_lab(data$HHAsstSecurity) = num_lab(" 0 No @@ -13,18 +21,17 @@ val_lab(data$HHAsstSecurity) = num_lab(" 888 Don't know ") - -#creates a table of the weighted percentage of HHAsstSecurity by -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - - +# Create a table of the weighted percentage of HHAsstSecurity. HHAsstSecurity_table_wide <- data %>% drop_na(HHAsstSecurity) %>% - count(HHAsstSecurity_lab = as.character(HHAsstSecurity)) %>% # if weights are needed use instead the row below - #count(HHAsstSecurity_lab = as.character(HHAsstSecurity), wt = nameofweightvariable) + count(HHAsstSecurity_lab = as.character(HHAsstSecurity)) %>% mutate(Percentage = 100 * n / sum(n)) %>% ungroup() %>% select(-n) %>% pivot_wider(names_from = HHAsstSecurity_lab, values_from = Percentage, values_fill = 0) + +# Print the table. +print(HHAsstSecurity_table_wide) + +# End of Scripts. \ No newline at end of file From 788746abe3043e40cb70a13f8f9336447b521e8e Mon Sep 17 00:00:00 2001 From: nicolefindstar Date: Thu, 1 Aug 2024 11:21:07 +0200 Subject: [PATCH 2/6] Updated pro-CC-1-2, formatted SPSS and R, added Stata and Python --- Indicators/Protection-CRF-CC1-2/pro-CC-1-2.do | 21 +++++++++++++ Indicators/Protection-CRF-CC1-2/pro-CC-1-2.py | 31 +++++++++++++++++++ .../Protection-CRF-CC1-2/pro-CC-1-2.sps | 18 ++++++++--- .../pro-CC-1-2_tidyverse.R | 29 ++++++++++------- 4 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 Indicators/Protection-CRF-CC1-2/pro-CC-1-2.do create mode 100644 Indicators/Protection-CRF-CC1-2/pro-CC-1-2.py diff --git a/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.do b/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.do new file mode 100644 index 0000000..0d6d713 --- /dev/null +++ b/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.do @@ -0,0 +1,21 @@ +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Access Challenges Indicator +*------------------------------------------------------------------------------* + +* This script processes the access challenges indicator by assessing +* whether households have been unable to access WFP assistance one or more times. + +* Define variable and value labels. +label variable HHAsstAccess "Have you or any member of your household been unable to access WFP assistance one or more times?" +label define HHAsstAccess_lbl 0 "No" 1 "Yes" 888 "Don't know" +label values HHAsstAccess HHAsstAccess_lbl + +* Display frequency of HHAsstAccess. +tabulate HHAsstAccess + +* Create a table of the weighted percentage of HHAsstAccess. +cap gen WeightHH = 1 +tabulate HHAsstAccess [aw = WeightHH] + +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.py b/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.py new file mode 100644 index 0000000..8a83883 --- /dev/null +++ b/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.py @@ -0,0 +1,31 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Access Challenges Indicator +#------------------------------------------------------------------------------# + +# This script processes the access challenges indicator by assessing +# whether households have been unable to access WFP assistance one or more times. + +import pandas as pd +import numpy as np + +# Add sample data. +#data = pd.read_csv("Static/PROP_AAP_CRF_Sample_Survey.csv") + +# Assign variable and value labels. +data['HHAsstAccess'] = data['HHAsstAccess'].astype('category') +data['HHAsstAccess'].cat.rename_categories({ + 0: 'No', + 1: 'Yes', + 888: 'Don\'t know' +}, inplace=True) + +# Create a table of the weighted percentage of HHAsstAccess. +HHAsstAccess_table = data['HHAsstAccess'].value_counts(normalize=True).reset_index() +HHAsstAccess_table.columns = ['HHAsstAccess', 'Percentage'] +HHAsstAccess_table['Percentage'] *= 100 + +# Print the table. +print(HHAsstAccess_table) + +# End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.sps b/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.sps index 6dc6ddc..ffdafe9 100644 --- a/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.sps +++ b/Indicators/Protection-CRF-CC1-2/pro-CC-1-2.sps @@ -1,7 +1,17 @@ -* Encoding: UTF-8. +******************************************************************************** +* WFP Standardized Scripts +* Access Challenges Indicator +******************************************************************************** -Variable labels HHAsstAccess ‘Have you or any member of your household been unable to access WFP assistance one or more times?’. +* This script processes the access challenges indicator by assessing +* whether households have been unable to access WFP assistance one or more times. -Value labels HHAsstAccess 1 'Yes' 0 'No ' 888 "Don't know". +* Define variable and value labels. -freq HHAsstAccess. +VARIABLE LABELS HHAsstAccess "Have you or any member of your household been unable to access WFP assistance one or more times?". +VALUE LABELS HHAsstAccess 1 'Yes' 0 'No' 888 'Don\'t know'. + +* Display frequency of HHAsstAccess. +FREQUENCIES VARIABLES = HHAsstAccess. + +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-2/pro-CC-1-2_tidyverse.R b/Indicators/Protection-CRF-CC1-2/pro-CC-1-2_tidyverse.R index 3681b3e..c653e0b 100644 --- a/Indicators/Protection-CRF-CC1-2/pro-CC-1-2_tidyverse.R +++ b/Indicators/Protection-CRF-CC1-2/pro-CC-1-2_tidyverse.R @@ -1,11 +1,19 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Access Challenges Indicator +#------------------------------------------------------------------------------# + +# This script processes the access challenges indicator by assessing +# whether households have been unable to access WFP assistance one or more times. + library(tidyverse) library(expss) library(labelled) -#add sample data -data <- read_csv("Static/PROP_AAP_CRF_Sample_Survey.csv") +# Add sample data. +#data <- read_csv("Static/PROP_AAP_CRF_Sample_Survey.csv") -#assign variable and value labels +# Assign variable and value labels. var_label(data$HHAsstAccess) <- "Have you or any member of your household been unable to access WFP assistance one or more times?" val_lab(data$HHAsstAccess) = num_lab(" 0 No @@ -13,20 +21,17 @@ val_lab(data$HHAsstAccess) = num_lab(" 888 Don't know ") - -#creates a table of the weighted percentage of HHAsstAccess by -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - - +# Create a table of the weighted percentage of HHAsstAccess. HHAsstAccess_table_wide <- data %>% drop_na(HHAsstAccess) %>% - count(HHAsstAccess_lab = as.character(HHAsstAccess)) %>% # if weights are needed use instead the row below - #count(HHAsstAccess_lab = as.character(HHAsstAccess), wt = nameofweightvariable) + count(HHAsstAccess_lab = as.character(HHAsstAccess)) %>% mutate(Percentage = 100 * n / sum(n)) %>% ungroup() %>% select(-n) %>% pivot_wider(names_from = HHAsstAccess_lab, values_from = Percentage, values_fill = 0) - +# Print the table. +print(HHAsstAccess_table_wide) + +# End of Scripts. \ No newline at end of file From a88e61b6da4d1aebf1fd2337bb79ef2f11e6d67e Mon Sep 17 00:00:00 2001 From: nicolefindstar Date: Thu, 1 Aug 2024 11:29:33 +0200 Subject: [PATCH 3/6] Updated pro-CC-1-3, formatted SPSS and R, added Stata and Python --- Indicators/Protection-CRF-CC1-3/pro-CC-1-3.do | 30 +++++++++++ Indicators/Protection-CRF-CC1-3/pro-CC-1-3.py | 39 +++++++++++++++ .../Protection-CRF-CC1-3/pro-CC-1-3.sps | 45 +++++++++++------ .../pro-CC-1-3_tidyverse.R | 50 +++++++++++++++++++ .../pro-CC1-3_tidyverse.R | 45 ----------------- 5 files changed, 148 insertions(+), 61 deletions(-) create mode 100644 Indicators/Protection-CRF-CC1-3/pro-CC-1-3.do create mode 100644 Indicators/Protection-CRF-CC1-3/pro-CC-1-3.py create mode 100644 Indicators/Protection-CRF-CC1-3/pro-CC-1-3_tidyverse.R delete mode 100644 Indicators/Protection-CRF-CC1-3/pro-CC1-3_tidyverse.R diff --git a/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.do b/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.do new file mode 100644 index 0000000..692ebd8 --- /dev/null +++ b/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.do @@ -0,0 +1,30 @@ +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Respect and Dignity in WFP Programmes +*------------------------------------------------------------------------------* + +* This script processes the indicators related to whether households feel +* respected and dignified while engaging in WFP programmes. + +* Define variable and value labels. +label variable HHAsstRespect "Do you think WFP and/or partner staff have treated you and members of your household respectfully?" +label variable HHDTPDign "Do you think the conditions of WFP programme sites are dignified?" + +label define YesNo 1 "Yes" 0 "No" +label values HHAsstRespect HHDTPDign YesNo + +* Cross tabulate to see how many are "Yes" in both questions. +tabulate HHAsstRespect HHDTPDign + +* Calculate indicator. +gen HHAsstRespectDign = (HHAsstRespect == 1 & HHDTPDign == 1) +replace HHAsstRespectDign = 0 if HHAsstRespectDign == . + +label variable HHAsstRespectDign "Treated with respect while engaging in WFP programs" +label define RespectDignity 0 "No" 1 "Yes" +label values HHAsstRespectDign RespectDignity + +* Display frequency of HHAsstRespectDign. +tabulate HHAsstRespectDign + +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.py b/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.py new file mode 100644 index 0000000..92d56cb --- /dev/null +++ b/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.py @@ -0,0 +1,39 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Respect and Dignity in WFP Programmes +#------------------------------------------------------------------------------# + +# This script processes the indicators related to whether households feel +# respected and dignified while engaging in WFP programmes. + +import pandas as pd +import numpy as np + +# Add sample data. +#data = pd.read_csv("Static/PROP_AAP_CRF_Sample_Survey.csv") + +# Assign variable and value labels. +data['HHAsstRespect'] = data['HHAsstRespect'].astype('category') +data['HHAsstRespect'].cat.rename_categories({ + 0: 'No', + 1: 'Yes' +}, inplace=True) + +data['HHDTPDign'] = data['HHDTPDign'].astype('category') +data['HHDTPDign'].cat.rename_categories({ + 0: 'No', + 1: 'Yes' +}, inplace=True) + +# Calculate indicator. +data['HHAsstRespectDign'] = np.where((data['HHAsstRespect'] == 'Yes') & (data['HHDTPDign'] == 'Yes'), 'Yes', 'No') + +# Create a table of the weighted percentage of HHAsstRespectDign. +HHAsstRespectDign_table = data['HHAsstRespectDign'].value_counts(normalize=True).reset_index() +HHAsstRespectDign_table.columns = ['HHAsstRespectDign', 'Percentage'] +HHAsstRespectDign_table['Percentage'] *= 100 + +# Print the table. +print(HHAsstRespectDign_table) + +# End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.sps b/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.sps index 7a1ea4f..ba9faea 100644 --- a/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.sps +++ b/Indicators/Protection-CRF-CC1-3/pro-CC-1-3.sps @@ -1,29 +1,42 @@ -* Encoding: UTF-8. +******************************************************************************** +* WFP Standardized Scripts +* Respect and Dignity in WFP Programmes +******************************************************************************** -Variable labels HHAsstRespect ‘Do you think WFPandor partner staff have treated you and members of your household respectfully? ’. +* This script processes the indicators related to whether households feel +* respected and dignified while engaging in WFP programmes. -Variable labels HHDTPDign ‘Do you think the conditions of WFP programme sites are dignified?’. +* Define variable and value labels. +VARIABLE LABELS + HHAsstRespect "Do you think WFP and/or partner staff have treated you and members of your household respectfully?". +VARIABLE LABELS + HHDTPDign "Do you think the conditions of WFP programme sites are dignified?". -Value labels HHAsstRespect HHDTPDign 1 'Yes' 0 'No'. - -* cross tab first to see how many are "Yes" in both questions +VALUE LABELS HHAsstRespect HHDTPDign + 1 'Yes' + 0 'No'. +* Cross tabulate to see how many are "Yes" in both questions. CROSSTABS /TABLES=HHAsstRespect BY HHDTPDign /FORMAT=AVALUE TABLES /CELLS=COUNT /COUNT ROUND CELL. +DO IF (HHAsstRespect = 1) & (HHDTPDign = 1). + COMPUTE HHAsstRespectDign = 1. +ELSE. + COMPUTE HHAsstRespectDign = 0. +END IF. -do if (HHAsstRespect = 1) & (HHDTPDign = 1). -compute HHAsstRespectDign = 1. -Else. -Compute HHAsstRespectDign = 0. -End if. +VARIABLE LABELS + HHAsstRespectDign "Treated with respect while engaging in WFP programs". +VALUE LABELS + HHAsstRespectDign + 0 'No' + 1 'Yes'. -variable labels HHAsstRespectDign "Treated with respect while engaging in WFP programs". -value labels HHAsstRespectDign -0 "No" -1 "Yes". +* Display frequency of HHAsstRespectDign. +FREQUENCIES VARIABLES = HHAsstRespectDign. -freq HHAsstRespectDign. +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-3/pro-CC-1-3_tidyverse.R b/Indicators/Protection-CRF-CC1-3/pro-CC-1-3_tidyverse.R new file mode 100644 index 0000000..df89e7a --- /dev/null +++ b/Indicators/Protection-CRF-CC1-3/pro-CC-1-3_tidyverse.R @@ -0,0 +1,50 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Respect and Dignity in WFP Programmes +#------------------------------------------------------------------------------# + +# This script processes the indicators related to whether households feel +# respected and dignified while engaging in WFP programmes. + +library(tidyverse) +library(expss) +library(labelled) + +# Add sample data. +#data <- read_csv("Static/PROP_AAP_CRF_Sample_Survey.csv") + +# Assign variable and value labels. +var_label(data$HHAsstRespect) <- "Do you think WFP and/or partner staff have treated you and members of your household respectfully?" +var_label(data$HHDTPDign) <- "Do you think the conditions of WFP programme sites are dignified?" + +data <- data %>% + mutate(across(c(HHAsstRespect, HHDTPDign), ~labelled(., labels = c( + "No" = 0, + "Yes" = 1 + )))) + +# Calculate indicator and assign variable label & name. +data <- data %>% mutate(HHAsstRespectDign = case_when( + HHAsstRespect == 1 & HHDTPDign == 1 ~ 1, + TRUE ~ 0 +)) +var_label(data$HHAsstRespectDign) <- "Treated with respect while engaging in WFP programs" +val_lab(data$HHAsstRespectDign) = num_lab(" + 0 No + 1 Yes +") + +# Create a table of the weighted percentage of HHAsstRespectDign. +HHAsstRespectDign_table_wide <- data %>% + drop_na(HHAsstRespectDign) %>% + count(HHAsstRespectDign_lab = as.character(HHAsstRespectDign)) %>% + mutate(Percentage = 100 * n / sum(n)) %>% + ungroup() %>% select(-n) %>% + pivot_wider(names_from = HHAsstRespectDign_lab, + values_from = Percentage, + values_fill = 0) + +# Print the table. +print(HHAsstRespectDign_table_wide) + +# End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-3/pro-CC1-3_tidyverse.R b/Indicators/Protection-CRF-CC1-3/pro-CC1-3_tidyverse.R deleted file mode 100644 index be7243b..0000000 --- a/Indicators/Protection-CRF-CC1-3/pro-CC1-3_tidyverse.R +++ /dev/null @@ -1,45 +0,0 @@ -library(tidyverse) -library(labelled) -library(expss) - -#add sample data -data <- read_csv("Static/PROP_AAP_CRF_Sample_Survey.csv") - -#assign variable and value labels -var_label(data$HHAsstRespect) <- "Do you think WFPandor partner staff have treated you and members of your household respectfully?" -var_label(data$HHDTPDign) <- "Do you think the conditions of WFP programme sites are dignified?" - -data <- data %>% - mutate(across(c(HHAsstRespect, HHDTPDign), ~labelled(., labels = c( - "No" = 0, - "Yes" = 1 - )))) - -#calculate indicator and assign variable label & name -data <- data %>% mutate(HHAsstRespectDign = case_when( - HHAsstRespect == 1 & HHDTPDign == 1 ~ 1, - TRUE ~ 0 -)) -var_label(data$HHAsstRespectDign) <- "Treated with respect while engaging in WFP programs" -val_lab(data$HHAsstRespectDign) = num_lab(" - 0 No - 1 Yes -") - - -#creates a table of the weighted percentage of HHAsstRespectDign by -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - - -HHAsstRespectDign_table_wide <- data %>% - drop_na(HHAsstRespectDign) %>% - count(HHAsstRespectDign_lab = as.character(HHAsstRespectDign)) %>% # if weights are needed use instead the row below - #count(HHAsstRespectDign_lab = as.character(HHAsstRespectDign), wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = HHAsstRespectDign_lab, - values_from = Percentage, - values_fill = 0) - - From 02a6685d449af6ce511242fccaa19a6937aafccd Mon Sep 17 00:00:00 2001 From: nicolefindstar Date: Thu, 1 Aug 2024 11:42:18 +0200 Subject: [PATCH 4/6] Updated pro-CC-2-1, formatted SPSS and R, added Stata and Python --- Indicators/Protection-CRF-CC2-1/pro-CC-2-1.do | 39 +++++++++++++ Indicators/Protection-CRF-CC2-1/pro-CC-2-1.py | 58 +++++++++++++++++++ .../Protection-CRF-CC2-1/pro-CC-2-1.sps | 21 +++++++ ...2-1_tidyverse.R => pro-CC-2-1_tidyverse.R} | 42 ++++++-------- Indicators/Protection-CRF-CC2-1/pro-CC2-1.sps | 29 ---------- 5 files changed, 136 insertions(+), 53 deletions(-) create mode 100644 Indicators/Protection-CRF-CC2-1/pro-CC-2-1.do create mode 100644 Indicators/Protection-CRF-CC2-1/pro-CC-2-1.py create mode 100644 Indicators/Protection-CRF-CC2-1/pro-CC-2-1.sps rename Indicators/Protection-CRF-CC2-1/{pro-CC2-1_tidyverse.R => pro-CC-2-1_tidyverse.R} (50%) delete mode 100644 Indicators/Protection-CRF-CC2-1/pro-CC2-1.sps diff --git a/Indicators/Protection-CRF-CC2-1/pro-CC-2-1.do b/Indicators/Protection-CRF-CC2-1/pro-CC-2-1.do new file mode 100644 index 0000000..9a64b47 --- /dev/null +++ b/Indicators/Protection-CRF-CC2-1/pro-CC-2-1.do @@ -0,0 +1,39 @@ +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Access to Information in WFP Programmes (pro-CC-2-1) +*------------------------------------------------------------------------------* + +* This script processes the indicators related to households' access to information +* about their entitlements, selection criteria, information comprehension, and +* reporting misconduct in WFP programmes. + +* Define variable and value labels. +label variable HHAsstKnowEnt "Have you been told exactly what you are entitled to receive in terms of commodities/quantities or cash? Please describe your entitlements" +label variable HHAsstKnowPeople "Do you know how people were chosen to receive assistance? Please describe how they were chosen" +label variable HHAsstRecInfo "Did you receive the information in a way that you could easily understand?" +label variable HHAsstReportMisc "Do you know how to report misconduct from WFP or partners, including asking for (sexual) favours or money in exchange of assistance?" + +label define YesNo 1 "Yes" 0 "No" +label define RecInfo 1 "Yes" 0 "No" 2 "I never received information" + +label values HHAsstKnowEnt HHAsstKnowPeople HHAsstReportMisc YesNo +label values HHAsstRecInfo RecInfo + +* Display frequency tables. +tabulate HHAsstKnowEnt +tabulate HHAsstKnowPeople +tabulate HHAsstRecInfo +tabulate HHAsstReportMisc + +* Compute the indicator for accessible information. +gen HHAcessInfo = 0 +replace HHAcessInfo = 1 if HHAsstKnowEnt == 1 & HHAsstKnowPeople == 1 & HHAsstRecInfo == 1 & HHAsstReportMisc == 1 + +label variable HHAcessInfo "Provided with accessible information about the programme" +label define AccessInfo 0 "No" 1 "Yes" +label values HHAcessInfo AccessInfo + +* Display frequency table for the indicator. +tabulate HHAcessInfo + +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC2-1/pro-CC-2-1.py b/Indicators/Protection-CRF-CC2-1/pro-CC-2-1.py new file mode 100644 index 0000000..2293cc2 --- /dev/null +++ b/Indicators/Protection-CRF-CC2-1/pro-CC-2-1.py @@ -0,0 +1,58 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Access to Information in WFP Programmes (pro-CC-2-1) +#------------------------------------------------------------------------------# + +# This script processes the indicators related to households' access to information +# about their entitlements, selection criteria, information comprehension, and +# reporting misconduct in WFP programmes. + +import pandas as pd +import numpy as np + +# Add sample data. +#data = pd.read_csv("Static/PROP_AAP_CRF_Sample_Survey.csv") + +# Assign variable and value labels. +data['HHAsstKnowEnt'] = data['HHAsstKnowEnt'].astype('category') +data['HHAsstKnowEnt'].cat.rename_categories({ + 0: 'No', + 1: 'Yes' +}, inplace=True) + +data['HHAsstKnowPeople'] = data['HHAsstKnowPeople'].astype('category') +data['HHAsstKnowPeople'].cat.rename_categories({ + 0: 'No', + 1: 'Yes' +}, inplace=True) + +data['HHAsstRecInfo'] = data['HHAsstRecInfo'].astype('category') +data['HHAsstRecInfo'].cat.rename_categories({ + 0: 'No', + 1: 'Yes', + 2: 'I never received information' +}, inplace=True) + +data['HHAsstReportMisc'] = data['HHAsstReportMisc'].astype('category') +data['HHAsstReportMisc'].cat.rename_categories({ + 0: 'No', + 1: 'Yes' +}, inplace=True) + +# Calculate indicator. +data['HHAcessInfo'] = np.where( + (data['HHAsstKnowEnt'] == 'Yes') & + (data['HHAsstKnowPeople'] == 'Yes') & + (data['HHAsstRecInfo'] == 'Yes') & + (data['HHAsstReportMisc'] == 'Yes'), 'Yes', 'No' +) + +# Create a table of the weighted percentage of HHAcessInfo. +HHAcessInfo_table = data['HHAcessInfo'].value_counts(normalize=True).reset_index() +HHAcessInfo_table.columns = ['HHAcessInfo', 'Percentage'] +HHAcessInfo_table['Percentage'] *= 100 + +# Print the table. +print(HHAcessInfo_table) + +# End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC2-1/pro-CC-2-1.sps b/Indicators/Protection-CRF-CC2-1/pro-CC-2-1.sps new file mode 100644 index 0000000..50d5438 --- /dev/null +++ b/Indicators/Protection-CRF-CC2-1/pro-CC-2-1.sps @@ -0,0 +1,21 @@ +******************************************************************************** +* WFP Standardized Scripts +* Access to Information in WFP Programmes (pro-CC-2-1) +******************************************************************************** + +* This script processes the indicators related to households' access to information +* about their entitlements, selection criteria, information comprehension, and +* reporting misconduct in WFP programmes. + +* Define variable and value labels. +VARIABLE LABELS + HHAsstKnowEnt "Have you been told exactly what you are entitled to receive in terms of commodities/quantities or cash? Please describe your entitlements". +VARIABLE LABELS + HHAsstKnowPeople "Do you know how people were chosen to receive assistance? Please describe how they were chosen". +VARIABLE LABELS + HHAsstRecInfo "Did you receive the information in a way that you could easily understand?". +VARIABLE LABELS + HHAsstReportMisc "Do you know how to report misconduct from WFP or partners, including asking for (sexual) favours or money in exchange of assistance?". + +VALUE LABELS + HHAsstKno \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC2-1/pro-CC2-1_tidyverse.R b/Indicators/Protection-CRF-CC2-1/pro-CC-2-1_tidyverse.R similarity index 50% rename from Indicators/Protection-CRF-CC2-1/pro-CC2-1_tidyverse.R rename to Indicators/Protection-CRF-CC2-1/pro-CC-2-1_tidyverse.R index ad5223a..a6b6f72 100644 --- a/Indicators/Protection-CRF-CC2-1/pro-CC2-1_tidyverse.R +++ b/Indicators/Protection-CRF-CC2-1/pro-CC-2-1_tidyverse.R @@ -1,30 +1,37 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Access to Information in WFP Programmes (pro-CC-2-1) +#------------------------------------------------------------------------------# + +# This script processes the indicators related to households' access to information +# about their entitlements, selection criteria, information comprehension, and +# reporting misconduct in WFP programmes. + library(tidyverse) library(labelled) library(expss) -#add sample data -data <- read_csv("Static/PROP_AAP_CRF_Sample_Survey.csv") +# Add sample data. +#data <- read_csv("Static/PROP_AAP_CRF_Sample_Survey.csv") -#assign variable and value labels -var_label(data$HHAsstKnowEnt) <- "Have you been told exactly what you are entitled to receive in terms of commodities/quantities or cash? Please describe your entitlements" +# Assign variable and value labels. +var_label(data$HHAsstKnowEnt) <- "Have you been told exactly what you are entitled to receive in terms of commodities/quantities or cash? Please describe your entitlements" var_label(data$HHAsstKnowPeople) <- "Do you know how people were chosen to receive assistance? Please describe how they were chosen" -var_label(data$HHAsstRecInfo) <- "Did you receive the information in a way that you could easily understand?" +var_label(data$HHAsstRecInfo) <- "Did you receive the information in a way that you could easily understand?" var_label(data$HHAsstReportMisc) <- "Do you know how to report misconduct from WFP or partners, including asking for (sexual) favours or money in exchange of assistance?" data <- data %>% mutate(across(c(HHAsstKnowEnt, HHAsstKnowPeople, HHAsstReportMisc), ~labelled(., labels = c( "No" = 0, "Yes" = 1 - )))) -data <- data %>% + )))) %>% mutate(across(c(HHAsstRecInfo), ~labelled(., labels = c( "No" = 0, "Yes" = 1, "I never received information" = 2 )))) - -#calculate indicator and assign variable label & name +# Calculate indicator and assign variable label & name. data <- data %>% mutate(HHAcessInfo = case_when( HHAsstKnowEnt == 1 & HHAsstKnowPeople == 1 & HHAsstRecInfo == 1 & HHAsstReportMisc == 1 ~ 1, TRUE ~ 0 @@ -35,20 +42,7 @@ val_lab(data$HHAcessInfo) = num_lab(" 1 Yes ") - -#creates a table of the weighted percentage of HHAcessInfo by -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - - +# Create a table of the weighted percentage of HHAcessInfo. HHAcessInfo_table_wide <- data %>% drop_na(HHAcessInfo) %>% - count(HHAcessInfo_lab = as.character(HHAcessInfo)) %>% # if weights are needed use instead the row below - #count(HHAcessInfo_lab = as.character(HHAcessInfo), wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = HHAcessInfo_lab, - values_from = Percentage, - values_fill = 0) - - + cou \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC2-1/pro-CC2-1.sps b/Indicators/Protection-CRF-CC2-1/pro-CC2-1.sps deleted file mode 100644 index 9cd8271..0000000 --- a/Indicators/Protection-CRF-CC2-1/pro-CC2-1.sps +++ /dev/null @@ -1,29 +0,0 @@ -* Encoding: UTF-8. - -* Encoding: UTF-8. - -Variable labels HHAsstKnowEnt 'Have you been told exactly what you are entitled to receive in terms of commodities/quantities or cash? Please describe your entitlements'. -Variable labels HHAsstKnowPeople 'Do you know how people were chosen to receive assistance? Please describe how they were chosen'. -Variable labels HHAsstRecInfo 'Did you receive the information in a way that you could easily understand?'. -Variable labels HHAsstReportMisc 'Do you know how to report misconduct from WFP or partners, including asking for (sexual) favours or money in exchange of assistance?'. - - -Value labels HHAsstKnowEnt HHAsstKnowPeople HHAsstReportMisc 1 'Yes' 0 'No'. -Value labels HHAsstRecInfo 1 'Yes' 0 'No' 2 'I never received information'. - - -freq HHAsstKnowEnt HHAsstKnowPeople HHAsstRecInfo HHAsstReportMisc. - -do if (HHAsstKnowEnt = 1) & (HHAsstKnowPeople = 1) & (HHAsstRecInfo = 1) & (HHAsstReportMisc = 1). -compute HHAcessInfo = 1. -Else. -Compute HHAcessInfo = 0. -End if. - -variable labels HHAcessInfo "Provided with accessible information about the programme ". -value labels HHAcessInfo -0 "No" -1 "Yes". - -freq HHAcessInfo. - From 6d646c4cbaf3f29110282cd5cc329bb117148efd Mon Sep 17 00:00:00 2001 From: nicolefindstar Date: Thu, 1 Aug 2024 11:59:11 +0200 Subject: [PATCH 5/6] Updated pro-CC-1-4 hoh, formatted SPSS and R, added Stata and Python --- .../Protection-CRF-CC1-4/pro-CC-1-4_hoh.do | 0 .../Protection-CRF-CC1-4/pro-CC-1-4_hoh.py | 60 +++++++++ .../Protection-CRF-CC1-4/pro-CC-1-4_hoh.sps | 114 +++++++++++------- .../pro-CC-1-4_hoh_tidyverse.R | 98 +++++++++++++++ .../pro-CC1-4_hoh_tidyverse.R | 96 --------------- 5 files changed, 229 insertions(+), 139 deletions(-) create mode 100644 Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.do create mode 100644 Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.py create mode 100644 Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh_tidyverse.R delete mode 100644 Indicators/Protection-CRF-CC1-4/pro-CC1-4_hoh_tidyverse.R diff --git a/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.do b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.do new file mode 100644 index 0000000..e69de29 diff --git a/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.py b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.py new file mode 100644 index 0000000..af6bfc2 --- /dev/null +++ b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.py @@ -0,0 +1,60 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Household Level Assistance (hoh) +#------------------------------------------------------------------------------# + +# This script processes the indicators related to the receipt of different types +# of assistance by households and the disability status of the head of the household. + +import pandas as pd +import numpy as np + +# Add sample data +#data = pd.read_csv("~/GitHub/RAMResourcesScripts/Static/PRO_WG_Sample_Survey/HoHMethod/PRO_WG_HoH_Sample_Survey.csv") + +# Assign variable and value labels +data = data.rename(columns={ + "HHAsstWFPRecCashYN1Y": "Did your household receive cash-based WFP assistance in the last 12 months?", + "HHAsstWFPRecInKindYN1Y": "Did your household receive in-kind WFP assistance in the last 12 months?", + "HHAsstWFPRecCapBuildYN1Y": "Did you household receive WFP capacity building assistance in the last 12 months?", + "HHHSex": "What is the sex of the head of the household?", + "HHHAge": "Age of the head of the household", + "HHHDisabSee": "Does the head of household have difficulty seeing, even if wearing glasses? Would you say…", + "HHHDisabHear": "Does the head of household have difficulty hearing, even if using a hearing aid(s)? Would you say…", + "HHHDisabWalk": "Does the head of household have difficulty walking or climbing steps? Would you say…", + "HHHDisabRemember": "Does the head of household have difficulty remembering or concentrating? Would you say…", + "HHHDisabUnderstand": "Using his or her usual language, does the head of household have difficulty communicating, for example understanding or being understood? Would you say…", + "HHHDisabWash": "Does the head of household have difficulty with self-care, such as washing all over or dressing? Would you say…" +}) + +data["HHAsstWFPRecCashYN1Y"] = data["HHAsstWFPRecCashYN1Y"].replace({0: "No", 1: "Yes"}) +data["HHAsstWFPRecInKindYN1Y"] = data["HHAsstWFPRecInKindYN1Y"].replace({0: "No", 1: "Yes"}) +data["HHAsstWFPRecCapBuildYN1Y"] = data["HHAsstWFPRecCapBuildYN1Y"].replace({0: "No", 1: "Yes"}) +data["HHHSex"] = data["HHHSex"].replace({0: "Female", 1: "Male"}) +difficulty_labels = {1: "No difficulty", 2: "Some difficulty", 3: "A lot of difficulty", 4: "Cannot do at all", 888: "Don't know", 999: "Refuse"} +data["HHHDisabSee"] = data["HHHDisabSee"].replace(difficulty_labels) +data["HHHDisabHear"] = data["HHHDisabHear"].replace(difficulty_labels) +data["HHHDisabWalk"] = data["HHHDisabWalk"].replace(difficulty_labels) +data["HHHDisabRemember"] = data["HHHDisabRemember"].replace(difficulty_labels) +data["HHHDisabUnderstand"] = data["HHHDisabUnderstand"].replace(difficulty_labels) +data["HHHDisabWash"] = data["HHHDisabWash"].replace(difficulty_labels) + +# Calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions +data["HHHDisabCat3"] = np.where(data[["HHHDisabSee", "HHHDisabHear", "HHHDisabWalk", "HHHDisabRemember", "HHHDisabUnderstand", "HHHDisabWash"]].apply(lambda x: x.isin(["A lot of difficulty", "Cannot do at all"]).any(), axis=1), "with disability (category 3 criteria)", "without disability (category 3 criteria)") + +# Create tables of the weighted percentage of type of assistance received by HHHDisabCat3 +# Cash-based assistance +cash_table = pd.crosstab(data["HHAsstWFPRecCashYN1Y"], data["HHHDisabCat3"], normalize='columns') * 100 + +# In-kind assistance +inkind_table = pd.crosstab(data["HHAsstWFPRecInKindYN1Y"], data["HHHDisabCat3"], normalize='columns') * 100 + +# Capacity building assistance +capacity_building_table = pd.crosstab(data["HHAsstWFPRecCapBuildYN1Y"], data["HHHDisabCat3"], normalize='columns') * 100 + +# Display results +print("Cash-based assistance table:\n", cash_table) +print("\nIn-kind assistance table:\n", inkind_table) +print("\nCapacity building assistance table:\n", capacity_building_table) + +# End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.sps b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.sps index 33ea95e..098f4ec 100644 --- a/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.sps +++ b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh.sps @@ -1,61 +1,89 @@ -* Encoding: UTF-8. - -*assign variable and value labels - -Variable Labels HHAsstWFPRecCashYN1Y "Did your household receive cash-based WFP assistance in the last 12 months?". -Variable Labels HHAsstWFPRecInKindYN1Y "Did your household receive in-kind WFP assistance in the last 12 months?". -Variable Labels HHAsstWFPRecCapBuildYN1Y "Did you household receive WFP capacity building assistance in the last 12 months?". - -Variable Labels HHHSex "What is the sex of the head of the household?". -Variable Labels HHHAge "Age of the head of the household". - -Variable Labels HHHDisabSee "Does the head of household have difficulty seeing, even if wearing glasses? Would you say…". -Variable Labels HHHDisabHear "Does the head of household have difficulty hearing, even if using a hearing aid(s)? Would you say…". -Variable Labels HHHDisabWalk "Does the head of household have difficulty remembering or concentrating? Would you say…". -Variable Labels HHHDisabRemember "Does the head of household have difficulty remembering or concentrating? Would you say…". -Variable Labels HHHDisabUnderstand "Using his or her usual language, does the head of household have difficulty communicating, for example understanding or being understood? Would you say…". -Variable Labels HHHDisabWash "Does the head of household have difficulty with self-care, such as washing all over or dressing? Would you say…". - - -Value labels HHAsstWFPRecCashYN1Y HHAsstWFPRecInKindYN1Y HHAsstWFPRecCapBuildYN1Y 0 'No' 1 'Yes'. -Value labels HHHSex 0 'Female' 1 'Male'. -Value labels HHHDisabSee HHHDisabHear HHHDisabWalk HHHDisabRemember HHHDisabUnderstand HHHDisabWash 1 'No difficulty' 2 'Some difficulty' 3 'A lot of difficulty' 4 'Cannot do at all' 888 "Don't know" 999 'Refuse'. - - -*calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions. - -Compute HHHDisabCat3 = 0. -if HHHDisabSee = 3 | HHHDisabSee = 4 | HHHDisabHear = 3 | HHHDisabHear = 4 | HHHDisabWalk = 3 | HHHDisabWalk = 4 | HHHDisabRemember = 3 | HHHDisabRemember = 4 | HHHDisabUnderstand = 3 | HHHDisabUnderstand = 4 | -HHHDisabWash = 3 | HHHDisabWash = 4 HHHDisabCat3 = 1. - -Value labels HHHDisabCat3 0 "without disability (category 3 criteria)" 1 "with disability (category 3 criteria)". - - -*creates a table of the percentage of type of assistance recieve by PDisabCat3 - - -*cash - +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Household Level Assistance (hoh) +*------------------------------------------------------------------------------* + +* This script processes the indicators related to the receipt of different types +* of assistance by households and the disability status of the head of the household. + +* Define variable and value labels. +VARIABLE LABELS + HHAsstWFPRecCashYN1Y "Did your household receive cash-based WFP assistance in the last 12 months?". +VARIABLE LABELS + HHAsstWFPRecInKindYN1Y "Did your household receive in-kind WFP assistance in the last 12 months?". +VARIABLE LABELS + HHAsstWFPRecCapBuildYN1Y "Did you household receive WFP capacity building assistance in the last 12 months?". + +VARIABLE LABELS + HHHSex "What is the sex of the head of the household?". +VARIABLE LABELS + HHHAge "Age of the head of the household". + +VARIABLE LABELS + HHHDisabSee "Does the head of household have difficulty seeing, even if wearing glasses? Would you say…". +VARIABLE LABELS + HHHDisabHear "Does the head of household have difficulty hearing, even if using a hearing aid(s)? Would you say…". +VARIABLE LABELS + HHHDisabWalk "Does the head of household have difficulty walking or climbing steps? Would you say…". +VARIABLE LABELS + HHHDisabRemember "Does the head of household have difficulty remembering or concentrating? Would you say…". +VARIABLE LABELS + HHHDisabUnderstand "Using his or her usual language, does the head of household have difficulty communicating, for example understanding or being understood? Would you say…". +VARIABLE LABELS + HHHDisabWash "Does the head of household have difficulty with self-care, such as washing all over or dressing? Would you say…". + +VALUE LABELS + HHAsstWFPRecCashYN1Y + HHAsstWFPRecInKindYN1Y + HHAsstWFPRecCapBuildYN1Y + 0 'No' + 1 'Yes'. +VALUE LABELS + HHHSex + 0 'Female' + 1 'Male'. +VALUE LABELS + HHHDisabSee + HHHDisabHear + HHHDisabWalk + HHHDisabRemember + HHHDisabUnderstand + HHHDisabWash + 1 'No difficulty' + 2 'Some difficulty' + 3 'A lot of difficulty' + 4 'Cannot do at all' + 888 "Don't know" + 999 'Refuse'. + +* Calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions. +COMPUTE HHHDisabCat3 = 0. +IF HHHDisabSee = 3 | HHHDisabSee = 4 | HHHDisabHear = 3 | HHHDisabHear = 4 | HHHDisabWalk = 3 | HHHDisabWalk = 4 | HHHDisabRemember = 3 | HHHDisabRemember = 4 | HHHDisabUnderstand = 3 | HHHDisabUnderstand = 4 | HHHDisabWash = 3 | HHHDisabWash = 4 HHHDisabCat3 = 1. +VALUE LABELS HHHDisabCat3 + 0 "without disability (category 3 criteria)" + 1 "with disability (category 3 criteria)". + +* Create tables of the percentage of type of assistance received by HHHDisabCat3. + +* Cash-based assistance. CROSSTABS /TABLES=HHAsstWFPRecCashYN1Y BY HHHDisabCat3 /FORMAT=AVALUE TABLES /CELLS=COLUMN /COUNT ROUND CELL. -*inkind - +* In-kind assistance. CROSSTABS /TABLES=HHAsstWFPRecInKindYN1Y BY HHHDisabCat3 /FORMAT=AVALUE TABLES /CELLS=COLUMN /COUNT ROUND CELL. -*capacity building - +* Capacity building assistance. CROSSTABS /TABLES=HHAsstWFPRecCapBuildYN1Y BY HHHDisabCat3 /FORMAT=AVALUE TABLES /CELLS=COLUMN /COUNT ROUND CELL. - +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh_tidyverse.R b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh_tidyverse.R new file mode 100644 index 0000000..2f37f44 --- /dev/null +++ b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_hoh_tidyverse.R @@ -0,0 +1,98 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Household Level Assistance (hoh) +#------------------------------------------------------------------------------# + +# This script processes the indicators related to the receipt of different types +# of assistance by households and the disability status of the head of the household. + +library(tidyverse) +library(labelled) +library(expss) + +# Add sample data. +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/PRO_WG_Sample_Survey/HoHMethod/PRO_WG_HoH_Sample_Survey.csv") + +# Assign variable and value labels. +var_label(data$HHAsstWFPRecCashYN1Y) <- "Did your household receive cash-based WFP assistance in the last 12 months?" +var_label(data$HHAsstWFPRecInKindYN1Y) <- "Did your household receive in-kind WFP assistance in the last 12 months?" +var_label(data$HHAsstWFPRecCapBuildYN1Y) <- "Did you household receive WFP capacity building assistance in the last 12 months?" + +var_label(data$HHHSex) <- "What is the sex of the head of the household?" +var_label(data$HHHAge) <- "Age of the head of the household" + +var_label(data$HHHDisabSee) <- "Does the head of household have difficulty seeing, even if wearing glasses? Would you say…" +var_label(data$HHHDisabHear) <- "Does the head of household have difficulty hearing, even if using a hearing aid(s)? Would you say…" +var_label(data$HHHDisabWalk) <- "Does the head of household have difficulty walking or climbing steps? Would you say…" +var_label(data$HHHDisabRemember) <- "Does the head of household have difficulty remembering or concentrating? Would you say…" +var_label(data$HHHDisabUnderstand) <- "Using his or her usual language, does the head of household have difficulty communicating, for example understanding or being understood? Would you say…" +var_label(data$HHHDisabWash) <- "Does the head of household have difficulty with self-care, such as washing all over or dressing? Would you say…" + +data <- data %>% + mutate(across(c(HHAsstWFPRecCashYN1Y, HHAsstWFPRecInKindYN1Y, HHAsstWFPRecCapBuildYN1Y), ~labelled(., labels = c( + "No" = 0, + "Yes" = 1 + )))) + +val_lab(data$HHHSex) = num_lab(" + 0 Female + 1 Male +") + +data <- data %>% + mutate(across(c(HHHDisabSee, HHHDisabHear, HHHDisabWalk, HHHDisabRemember, HHHDisabUnderstand, HHHDisabWash), ~labelled(., labels = c( + "No difficulty" = 1, + "Some difficulty" = 2, + "A lot of difficulty" = 3, + "Cannot do at all" = 4, + "Don't know" = 888, + "Refuse" = 999 + )))) + +# Calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions. +data <- data %>% mutate(HHHDisabCat3 = case_when( + between(HHHDisabSee, 3, 4) | between(HHHDisabHear, 3, 4) | between(HHHDisabWalk, 3, 4) | between(HHHDisabRemember, 3, 4) | between(HHHDisabUnderstand, 3, 4) | between(HHHDisabWash, 3, 4) ~ 1, + TRUE ~ 0 +)) + +val_lab(data$HHHDisabCat3) = num_lab(" + 0 without disability (category 3 criteria) + 1 with disability (category 3 criteria) +") + +# Create tables of the weighted percentage of type of assistance received by HHHDisabCat3. + +# Cash-based assistance. +HHAsstWFPRecCashYN1Y_table_wide <- data %>% + group_by(HHHDisabCat3_lab = as_factor(HHHDisabCat3)) %>% + drop_na(HHAsstWFPRecCashYN1Y) %>% + count(HHAsstWFPRecCashYN1Y_lab = as_factor(HHAsstWFPRecCashYN1Y)) %>% + mutate(Percentage = 100 * n / sum(n)) %>% + ungroup() %>% select(-n) %>% + pivot_wider(names_from = HHAsstWFPRecCashYN1Y_lab, + values_from = Percentage, + values_fill = 0) + +# In-kind assistance. +HHAsstWFPRecInKindYN1Y_table_wide <- data %>% + group_by(HHHDisabCat3_lab = as_factor(HHHDisabCat3)) %>% + drop_na(HHAsstWFPRecInKindYN1Y) %>% + count(HHAsstWFPRecInKindYN1Y_lab = as_factor(HHAsstWFPRecInKindYN1Y)) %>% + mutate(Percentage = 100 * n / sum(n)) %>% + ungroup() %>% select(-n) %>% + pivot_wider(names_from = HHAsstWFPRecInKindYN1Y_lab, + values_from = Percentage, + values_fill = 0) + +# Capacity building assistance. +HHAsstWFPRecCapBuildYN1Y_table_wide <- data %>% + group_by(HHHDisabCat3_lab = as_factor(HHHDisabCat3)) %>% + drop_na(HHAsstWFPRecCapBuildYN1Y) %>% + count(HHAsstWFPRecCapBuildYN1Y_lab = as_factor(HHAsstWFPRecCapBuildYN1Y)) %>% + mutate(Percentage = 100 * n / sum(n)) %>% + ungroup() %>% select(-n) %>% + pivot_wider(names_from = HHAsstWFPRecCapBuildYN1Y_lab, + values_from = Percentage, + values_fill = 0) + +# End of Scripts. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-4/pro-CC1-4_hoh_tidyverse.R b/Indicators/Protection-CRF-CC1-4/pro-CC1-4_hoh_tidyverse.R deleted file mode 100644 index f439e68..0000000 --- a/Indicators/Protection-CRF-CC1-4/pro-CC1-4_hoh_tidyverse.R +++ /dev/null @@ -1,96 +0,0 @@ -library(tidyverse) -library(labelled) -library(expss) - -#add sample data -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/PRO_WG_Sample_Survey/HoHMethod/PRO_WG_HoH_Sample_Survey.csv") - - -#assign variable and value labels -var_label(data$HHAsstWFPRecCashYN1Y) <- "Did your household receive cash-based WFP assistance in the last 12 months?" -var_label(data$HHAsstWFPRecInKindYN1Y) <- "Did your household receive in-kind WFP assistance in the last 12 months?" -var_label(data$HHAsstWFPRecCapBuildYN1Y) <- "Did you household receive WFP capacity building assistance in the last 12 months?" - -var_label(data$HHHSex) <- "What is the sex of the head of the household?" -var_label(data$HHHAge) <- "Age of the head of the household" - -var_label(data$HHHDisabSee) <- "Does the head of household have difficulty seeing, even if wearing glasses? Would you say…" -var_label(data$HHHDisabHear) <- "Does the head of household have difficulty hearing, even if using a hearing aid(s)? Would you say…" -var_label(data$HHHDisabWalk) <- "Does the head of household have difficulty walking or climbing steps? Would you say…" -var_label(data$HHHDisabRemember) <- "Does the head of household have difficulty remembering or concentrating? Would you say…" -var_label(data$HHHDisabUnderstand) <- "Using his or her usual language, does the head of household hav e difficulty communicating, for example understanding or being understood? Would you say…" -var_label(data$HHHDisabWash) <- "Does the head of household have difficulty with self-care, such as washing all over or dressing? Would you say…" - - -data <- data %>% - mutate(across(c(HHAsstWFPRecCashYN1Y, HHAsstWFPRecInKindYN1Y, HHAsstWFPRecCapBuildYN1Y), ~labelled(., labels = c( - "No" = 0, - "Yes" = 1 - )))) - -val_lab(data$HHHSex) = num_lab(" - 0 Female - 1 Male -") - -data <- data %>% - mutate(across(c(HHHDisabSee,HHHDisabHear,HHHDisabWalk,HHHDisabRemember,HHHDisabUnderstand,HHHDisabWash), ~labelled(., labels = c( - "No difficulty" = 1, - "Some difficulty" = 2, - "A lot of difficulty" = 3, - "Cannot do at all" = 4, - "Don't know" = 888, - "Refuse" = 999 - )))) - -#calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions. -data <- data %>% mutate(HHHDisabCat3 = case_when( - between(HHHDisabSee,3,4) | between(HHHDisabHear,3,4) | between(HHHDisabWalk,3,4) | between(HHHDisabRemember,3,4) | between(HHHDisabUnderstand,3,4)| between(HHHDisabWash,3,4) ~ 1, - TRUE ~ 0 -)) - -val_lab(data$HHHDisabCat3) = num_lab(" - 0 without disability (category 3 criteria) - 1 with disability (category 3 criteria) -") - - -#creates a table of the weighted percentage of type of assistance recieve by HHHDisabCat3 -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - -#cash -HHAsstWFPRecCashYN1Y_table_wide <- data %>% group_by(HHHDisabCat3_lab = as_factor(HHHDisabCat3)) %>% - drop_na(HHAsstWFPRecCashYN1Y) %>% - count(HHAsstWFPRecCashYN1Y_lab = as_factor(HHAsstWFPRecCashYN1Y)) %>% # if weights are needed use instead the row below - #count(HHAsstWFPRecCashYN1Y_lab = as.character(HHAsstWFPRecCashYN1Y), wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = HHAsstWFPRecCashYN1Y_lab, - values_from = Percentage, - values_fill = 0) - -#inkind -HHAsstWFPRecInKindYN1Y_table_wide <- data %>% group_by(HHHDisabCat3_lab = as_factor(HHHDisabCat3)) %>% - drop_na(HHAsstWFPRecInKindYN1Y) %>% - count(HHAsstWFPRecInKindYN1Y_lab = as_factor(HHAsstWFPRecInKindYN1Y)) %>% # if weights are needed use instead the row below - #count(HHAsstWFPRecInKindYN1Y_lab = as.character(HHAsstWFPRecInKindYN1Y), wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = HHAsstWFPRecInKindYN1Y_lab, - values_from = Percentage, - values_fill = 0) - -#capacity building -HHAsstWFPRecCapBuildYN1Y_table_wide <- data %>% group_by(HHHDisabCat3_lab = as_factor(HHHDisabCat3)) %>% - drop_na(HHAsstWFPRecCapBuildYN1Y) %>% - count(HHAsstWFPRecCapBuildYN1Y_lab = as_factor(HHAsstWFPRecCapBuildYN1Y)) %>% # if weights are needed use instead the row below - #count(HHAsstWFPRecCapBuildYN1Y_lab = as.character(HHAsstWFPRecCapBuildYN1Y), wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from =HHAsstWFPRecCapBuildYN1Y_lab, - values_from = Percentage, - values_fill = 0) - - - From ae0ff48c8f48e8ef2817f077cb9ab8b1504a429c Mon Sep 17 00:00:00 2001 From: nicolefindstar Date: Thu, 1 Aug 2024 12:25:19 +0200 Subject: [PATCH 6/6] Updated pro-CC-1-4 for roster, formatted SPSS and R, added Stata and Python --- .../Protection-CRF-CC1-4/pro-CC-1-4_roster.do | 90 +++++++++ .../Protection-CRF-CC1-4/pro-CC-1-4_roster.py | 101 +++++++++++ .../pro-CC-1-4_roster.sps | 171 ++++++++++-------- ...yverse.R => pro-CC-1-4_roster_tidyverse.R} | 104 ++++++----- 4 files changed, 344 insertions(+), 122 deletions(-) create mode 100644 Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.do create mode 100644 Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.py rename Indicators/Protection-CRF-CC1-4/{pro-CC1-4_roster_tidyverse.R => pro-CC-1-4_roster_tidyverse.R} (50%) diff --git a/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.do b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.do new file mode 100644 index 0000000..cc683db --- /dev/null +++ b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.do @@ -0,0 +1,90 @@ +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Disability Status and Assistance Received (Roster Method) +*------------------------------------------------------------------------------* +/* +Note: This script is based on the assumption that the dataset has already +been imported and includes variables related to disability status and +assistance received. + +The following variables should have been defined before running this script: +- TechnicalAdd_submodule/HHAsstWFPRecCashYN1Y +- TechnicalAdd_submodule/HHAsstWFPRecInKindYN1Y +- TechnicalAdd_submodule/HHAsstWFPRecCapBuildYN1Y +- Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers +*/ + +* Import dataset 1. +import delimited "C:\Users\b\Desktop\demo\RosterMethod\data.csv", clear + +* Rename to remove group names. +rename TechnicalAdd_submoduleHHAsstWFPRecCashYN1Y HHAsstWFPRecCashYN1Y +rename TechnicalAdd_submoduleHHAsstWFPRecInKindYN1Y HHAsstWFPRecInKindYN1Y +rename TechnicalAdd_submoduleHHAsstWFPRecCapBuildYN1Y HHAsstWFPRecCapBuildYN1Y +rename _index index + +* Save the first dataset. +save "C:\Users\b\Desktop\demo\RosterMethod\data1.dta", replace + +* Import dataset 2. +import delimited "C:\Users\b\Desktop\demo\RosterMethod\Demographic_module_DisabilityHHMemb_submodule_RepeatDisabHHMembers.csv", clear + +* Rename to remove group names. +rename Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_G PDisabAge +rename Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_F PDisabSex +rename Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_E PDisabSee +rename Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_D PDisabHear +rename Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_C PDisabWalk +rename Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_B PDisabRemember +rename Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_A PDisabUnderstand +rename Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe PDisabWash +rename _parent_index index + +* Save the second dataset. +save "C:\Users\b\Desktop\demo\RosterMethod\data2.dta", replace + +* Merge the datasets. +use "C:\Users\b\Desktop\demo\RosterMethod\data1.dta", clear +merge 1:1 index using "C:\Users\b\Desktop\demo\RosterMethod\data2.dta" + +* Assign variable and value labels. +label variable HHAsstWFPRecCashYN1Y "Did your household receive cash-based WFP assistance in the last 12 months?" +label variable HHAsstWFPRecInKindYN1Y "Did your household receive in-kind WFP assistance in the last 12 months?" +label variable HHAsstWFPRecCapBuildYN1Y "Did you household receive WFP capacity building assistance in the last 12 months?" + +label variable PDisabAge "What is the age of ${PDisabName}?" +label variable PDisabSex "What is the sex of ${PDisabName}?" +label variable PDisabSee "Does ${PDisabName} have difficulty seeing, even if wearing glasses? Would you say…" +label variable PDisabHear "Does ${PDisabName} have difficulty hearing, even if using a hearing aid(s)? Would you say…" +label variable PDisabWalk "Does ${PDisabName} have difficulty walking or climbing steps? Would you say…" +label variable PDisabRemember "Does ${PDisabName} have difficulty remembering or concentrating? Would you say…" +label variable PDisabUnderstand "Using your usual language, does ${PDisabName} have difficulty communicating, for example understanding or being understood? Would you say…" +label variable PDisabWash "Does ${PDisabName} have difficulty with self-care, such as washing all over or dressing? Would you say…" + +label define YesNo 0 "No" 1 "Yes" +label values HHAsstWFPRecCashYN1Y HHAsstWFPRecInKindYN1Y HHAsstWFPRecCapBuildYN1Y YesNo + +label define Sex 0 "Female" 1 "Male" +label values PDisabSex Sex + +label define Difficulty 1 "No difficulty" 2 "Some difficulty" 3 "A lot of difficulty" 4 "Cannot do at all" 888 "Don't know" 999 "Refuse" +label values PDisabSee PDisabHear PDisabWalk PDisabRemember PDisabUnderstand PDisabWash Difficulty + +* Calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions. +gen PDisabCat3 = 0 +replace PDisabCat3 = 1 if inlist(PDisabSee, 3, 4) | inlist(PDisabHear, 3, 4) | inlist(PDisabWalk, 3, 4) | inlist(PDisabRemember, 3, 4) | inlist(PDisabUnderstand, 3, 4) | inlist(PDisabWash, 3, 4) + +label define Cat3 0 "without disability (category 3 criteria)" 1 "with disability (category 3 criteria)" +label values PDisabCat3 Cat3 + +* Create tables of the percentage of type of assistance received by PDisabCat3. +* Cash. +tabulate HHAsstWFPRecCashYN1Y PDisabCat3, column + +* In-kind. +tabulate HHAsstWFPRecInKindYN1Y PDisabCat3, column + +* Capacity building. +tabulate HHAsstWFPRecCapBuildYN1Y PDisabCat3, column + +* End of Scripts \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.py b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.py new file mode 100644 index 0000000..c337fa0 --- /dev/null +++ b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.py @@ -0,0 +1,101 @@ +#------------------------------------------------------------------------------ +# WFP Standardized Scripts +# Disability Status and Assistance Received (Roster Method) +#------------------------------------------------------------------------------ +# +# Note: This script is based on the assumption that the dataset has already +# been imported and includes variables related to disability status and +# assistance received. +# +# The following variables should have been defined before running this script: +# - TechnicalAdd_submodule/HHAsstWFPRecCashYN1Y +# - TechnicalAdd_submodule/HHAsstWFPRecInKindYN1Y +# - TechnicalAdd_submodule/HHAsstWFPRecCapBuildYN1Y +# - Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers +#------------------------------------------------------------------------------ + +import pandas as pd + +# Add sample data +data = pd.read_csv("GitHub/RAMResourcesScripts/Static/PRO_WG_Sample_Survey/RosterMethod/Demographic_module_DisabilityHHMemb_submodule_RepeatDisabHHMembers.csv") +data2 = pd.read_csv("GitHub/RAMResourcesScripts/Static/PRO_WG_Sample_Survey/RosterMethod/data.csv") + +# Rename to remove group names +data2 = data2.rename(columns={ + 'TechnicalAdd_submodule/HHAsstWFPRecCashYN1Y': 'HHAsstWFPRecCashYN1Y', + 'TechnicalAdd_submodule/HHAsstWFPRecInKindYN1Y': 'HHAsstWFPRecInKindYN1Y', + 'TechnicalAdd_submodule/HHAsstWFPRecCapBuildYN1Y': 'HHAsstWFPRecCapBuildYN1Y', + '_index': 'index' +}) + +data = data.rename(columns={ + 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabAge': 'PDisabAge', + 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabSex': 'PDisabSex', + 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabSee': 'PDisabSee', + 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabHear': 'PDisabHear', + 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabWalk': 'PDisabWalk', + 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabRemember': 'PDisabRemember', + 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabUnderstand': 'PDisabUnderstand', + 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabWash': 'PDisabWash', + '_parent_index': 'index' +}) + +# Join dataset "data" & "data2" +data = data.merge(data2, on='index') + +# Assign variable and value labels (metadata) +var_labels = { + 'HHAsstWFPRecCashYN1Y': "Did your household receive cash-based WFP assistance in the last 12 months?", + 'HHAsstWFPRecInKindYN1Y': "Did your household receive in-kind WFP assistance in the last 12 months?", + 'HHAsstWFPRecCapBuildYN1Y': "Did you household receive WFP capacity building assistance in the last 12 months?", + 'PDisabAge': "What is the age of ${PDisabName}?", + 'PDisabSex': "What is the sex of ${PDisabName}?", + 'PDisabSee': "Does ${PDisabName} have difficulty seeing, even if wearing glasses? Would you say…", + 'PDisabHear': "Does ${PDisabName} have difficulty hearing, even if using a hearing aid(s)? Would you say…", + 'PDisabWalk': "Does ${PDisabName} have difficulty walking or climbing steps? Would you say…", + 'PDisabRemember': "Does ${PDisabName} have difficulty remembering or concentrating? Would you say…", + 'PDisabUnderstand': "Using your usual language, does ${PDisabName} have difficulty communicating, for example understanding or being understood? Would you say…", + 'PDisabWash': "Does ${PDisabName} have difficulty with self-care, such as washing all over or dressing? Would you say…" +} + +value_labels = { + 'HHAsstWFPRecCashYN1Y': {0: 'No', 1: 'Yes'}, + 'HHAsstWFPRecInKindYN1Y': {0: 'No', 1: 'Yes'}, + 'HHAsstWFPRecCapBuildYN1Y': {0: 'No', 1: 'Yes'}, + 'PDisabSex': {0: 'Female', 1: 'Male'}, + 'PDisabSee': {1: 'No difficulty', 2: 'Some difficulty', 3: 'A lot of difficulty', 4: 'Cannot do at all', 888: "Don't know", 999: 'Refuse'}, + 'PDisabHear': {1: 'No difficulty', 2: 'Some difficulty', 3: 'A lot of difficulty', 4: 'Cannot do at all', 888: "Don't know", 999: 'Refuse'}, + 'PDisabWalk': {1: 'No difficulty', 2: 'Some difficulty', 3: 'A lot of difficulty', 4: 'Cannot do at all', 888: "Don't know", 999: 'Refuse'}, + 'PDisabRemember': {1: 'No difficulty', 2: 'Some difficulty', 3: 'A lot of difficulty', 4: 'Cannot do at all', 888: "Don't know", 999: 'Refuse'}, + 'PDisabUnderstand': {1: 'No difficulty', 2: 'Some difficulty', 3: 'A lot of difficulty', 4: 'Cannot do at all', 888: "Don't know", 999: 'Refuse'}, + 'PDisabWash': {1: 'No difficulty', 2: 'Some difficulty', 3: 'A lot of difficulty', 4: 'Cannot do at all', 888: "Don't know", 999: 'Refuse'} +} + +# Apply variable labels +data = data.rename(columns=var_labels) + +# Apply value labels +for column, labels in value_labels.items(): + data[column] = data[column].map(labels) + +# Calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions +data['PDisabCat3'] = data[['PDisabSee', 'PDisabHear', 'PDisabWalk', 'PDisabRemember', 'PDisabUnderstand', 'PDisabWash']].apply(lambda x: any(i in [3, 4] for i in x), axis=1).astype(int) + +data['PDisabCat3'] = data['PDisabCat3'].map({0: 'without disability (category 3 criteria)', 1: 'with disability (category 3 criteria)'}) + +# Create tables of the percentage of type of assistance received by PDisabCat3 + +# Cash +HHAsstWFPRecCashYN1Y_table_wide = data.groupby('PDisabCat3')['HHAsstWFPRecCashYN1Y'].value_counts(normalize=True).unstack().fillna(0) * 100 + +# In-kind +HHAsstWFPRecInKindYN1Y_table_wide = data.groupby('PDisabCat3')['HHAsstWFPRecInKindYN1Y'].value_counts(normalize=True).unstack().fillna(0) * 100 + +# Capacity building +HHAsstWFPRecCapBuildYN1Y_table_wide = data.groupby('PDisabCat3')['HHAsstWFPRecCapBuildYN1Y'].value_counts(normalize=True).unstack().fillna(0) * 100 + +print("Cash assistance table:\n", HHAsstWFPRecCashYN1Y_table_wide) +print("\nIn-kind assistance table:\n", HHAsstWFPRecInKindYN1Y_table_wide) +print("\nCapacity building assistance table:\n", HHAsstWFPRecCapBuildYN1Y_table_wide) + +# Eng of Scripts \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.sps b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.sps index 872b5a0..50fb98b 100644 --- a/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.sps +++ b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster.sps @@ -1,10 +1,22 @@ -* Encoding: UTF-8. - -* import dataset 1 - +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Disability Status and Assistance Received (Roster) +*------------------------------------------------------------------------------* + +* Note: This script is based on the assumption that the dataset has already +* been imported and includes variables related to disability status and +* assistance received. + +* The following variables should have been defined before running this script: +* - TechnicalAdd_submodule/HHAsstWFPRecCashYN1Y +* - TechnicalAdd_submodule/HHAsstWFPRecInKindYN1Y +* - TechnicalAdd_submodule/HHAsstWFPRecCapBuildYN1Y +* - Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers +*------------------------------------------------------------------------------. + +* Import dataset 1. PRESERVE. SET DECIMAL DOT. - GET DATA /TYPE=TXT /FILE="C:\Users\b\Desktop\demo\RosterMethod\data.csv" /ENCODING='UTF8' @@ -14,22 +26,19 @@ GET DATA /TYPE=TXT /FIRSTCASE=2 /DATATYPEMIN PERCENTAGE=95.0 /VARIABLES= - TechnicalAdd_submoduleHHAsstWFPRecCashYN1Y AUTO - TechnicalAdd_submoduleHHAsstWFPRecInKindYN1Y AUTO - TechnicalAdd_submoduleHHAsstWFPRecCapBuildYN1Y AUTO - @_index AUTO + TechnicalAdd_submoduleHHAsstWFPRecCashYN1Y AUTO + TechnicalAdd_submoduleHHAsstWFPRecInKindYN1Y AUTO + TechnicalAdd_submoduleHHAsstWFPRecCapBuildYN1Y AUTO + @_index AUTO /MAP. RESTORE. - CACHE. EXECUTE. DATASET NAME DataSet1. -* import dataset 2 - +* Import dataset 2. PRESERVE. SET DECIMAL DOT. - GET DATA /TYPE=TXT /FILE= "C:\Users\b\Desktop\demo\RosterMethod\Demographic_module_DisabilityHHMemb_submodule_RepeatDisabHH"+ @@ -41,31 +50,27 @@ GET DATA /TYPE=TXT /FIRSTCASE=2 /DATATYPEMIN PERCENTAGE=95.0 /VARIABLES= - Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_H AUTO - Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_G AUTO - Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_F AUTO - Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_E AUTO - Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_D AUTO - Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_C AUTO - Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_B AUTO - Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_A AUTO - Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe AUTO - @_parent_index AUTO + Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_H AUTO + Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_G AUTO + Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_F AUTO + Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_E AUTO + Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_D AUTO + Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_C AUTO + Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_B AUTO + Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_A AUTO + Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe AUTO + @_parent_index AUTO /MAP. RESTORE. - CACHE. EXECUTE. DATASET NAME DataSet2. -*join two datasets - +* Join two datasets. DATASET ACTIVATE DataSet2. RENAME VARIABLES (@_parent_index = index). - DATASET ACTIVATE DataSet1. RENAME VARIABLES (@_index = index). - SORT CASES BY index. DATASET ACTIVATE DataSet2. SORT CASES BY index. @@ -75,86 +80,94 @@ MATCH FILES /TABLE=* /BY index. EXECUTE. - -*can only download repeat csv data as zip file from moda with group names - will update this code to remove group names -*rename to remove group names - because of the variable length SPSS changes name slightly - +* Rename to remove group names - because of the variable length SPSS changes name slightly. DATASET ACTIVATE DataSet1. - -RENAME VARIABLES (TechnicalAdd_submoduleHHAsstWFPRecCashYN1Y = HHAsstWFPRecCashYN1Y ). -RENAME VARIABLES (TechnicalAdd_submoduleHHAsstWFPRecInKindYN1Y =HHAsstWFPRecInKindYN1Y). +RENAME VARIABLES (TechnicalAdd_submoduleHHAsstWFPRecCashYN1Y = HHAsstWFPRecCashYN1Y). +RENAME VARIABLES (TechnicalAdd_submoduleHHAsstWFPRecInKindYN1Y = HHAsstWFPRecInKindYN1Y). RENAME VARIABLES (TechnicalAdd_submoduleHHAsstWFPRecCapBuildYN1Y = HHAsstWFPRecCapBuildYN1Y). - RENAME VARIABLES (Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_G = PDisabAge). RENAME VARIABLES (Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_F = PDisabSex). -RENAME VARIABLES (Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_E= PDisabSee). +RENAME VARIABLES (Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_E = PDisabSee). RENAME VARIABLES (Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_D = PDisabHear). RENAME VARIABLES (Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_C = PDisabWalk). RENAME VARIABLES (Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_B = PDisabRemember). RENAME VARIABLES (Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe_A = PDisabUnderstand). RENAME VARIABLES (Demographic_moduleDisabilityHHMemb_submoduleRepeatDisabHHMembe = PDisabWash). - -*assign variable and value labels - -Variable Labels HHAsstWFPRecCashYN1Y "Did your household receive cash-based WFP assistance in the last 12 months?". -Variable Labels HHAsstWFPRecInKindYN1Y "Did your household receive in-kind WFP assistance in the last 12 months?". -Variable Labels HHAsstWFPRecCapBuildYN1Y "Did you household receive WFP capacity building assistance in the last 12 months?". - -Variable Labels PDisabAge "What is the age of ${PDisabName}?". -Variable Labels PDisabSex "What is the sex of ${PDisabName}?". -Variable Labels PDisabSee "Does ${PDisabName} have difficulty seeing, even if wearing glasses? Would you say…". -Variable Labels PDisabHear "Does ${PDisabName} have difficulty hearing, even if using a hearing aid(s)? Would you say…". -Variable Labels PDisabWalk "Does ${PDisabName} have difficulty walking or climbing steps? Would you say…". -Variable Labels PDisabRemember "Does ${PDisabName} have difficulty walking or climbing steps? Would you say…". -Variable Labels PDisabUnderstand "Using your usual language, does ${PDisabName} have difficulty communicating, for example understanding or being understood? Would you say…". -Variable Labels PDisabWash "Does ${PDisabName} have difficulty with self-care, such as washing all over or dressing? Would you say…". - - -Value labels HHAsstWFPRecCashYN1Y HHAsstWFPRecInKindYN1Y HHAsstWFPRecCapBuildYN1Y 0 'No' 1 'Yes'. -Value labels PDisabSex 0 'Female' 1 'Male'. -Value labels PDisabSee PDisabHear PDisabWalk PDisabRemember PDisabUnderstand PDisabWash 1 'No difficulty' 2 'Some difficulty' 3 'A lot of difficulty' 4 'Cannot do at all' 888 "Don't know" 999 'Refuse'. - - -*calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions. - -Compute PDisabCat3 = 0. +* Assign variable and value labels. +Variable Labels + HHAsstWFPRecCashYN1Y "Did your household receive cash-based WFP assistance in the last 12 months?". +Variable Labels + HHAsstWFPRecInKindYN1Y "Did your household receive in-kind WFP assistance in the last 12 months?". +Variable Labels + HHAsstWFPRecCapBuildYN1Y "Did you household receive WFP capacity building assistance in the last 12 months?". + +Variable Labels + PDisabAge "What is the age of ${PDisabName}?". +Variable Labels + PDisabSex "What is the sex of ${PDisabName}?". +Variable Labels + PDisabSee "Does ${PDisabName} have difficulty seeing, even if wearing glasses? Would you say…". +Variable Labels + PDisabHear "Does ${PDisabName} have difficulty hearing, even if using a hearing aid(s)? Would you say…". +Variable Labels + PDisabWalk "Does ${PDisabName} have difficulty walking or climbing steps? Would you say…". +Variable Labels + PDisabRemember "Does ${PDisabName} have difficulty remembering or concentrating? Would you say…". +Variable Labels + PDisabUnderstand "Using your usual language, does ${PDisabName} have difficulty communicating, for example understanding or being understood? Would you say…". +Variable Labels + PDisabWash "Does ${PDisabName} have difficulty with self-care, such as washing all over or dressing? Would you say…". + +Value labels + HHAsstWFPRecCashYN1Y HHAsstWFPRecInKindYN1Y HHAsstWFPRecCapBuildYN1Y + 0 'No' + 1 'Yes'. + +Value labels + PDisabSex + 0 'Female' + 1 'Male'. + +Value labels + PDisabSee PDisabHear PDisabWalk PDisabRemember PDisabUnderstand PDisabWash + 1 'No difficulty' + 2 'Some difficulty' + 3 'A lot of difficulty' + 4 'Cannot do at all' + 888 "Don't know" + 999 'Refuse'. + +* Calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions. +Compute PDisabCat3 = 0. if PDisabSee = 3 | PDisabSee = 4 | PDisabHear = 3 | PDisabHear = 4 | PDisabWalk = 3 | PDisabWalk = 4 | PDisabRemember = 3 | PDisabRemember = 4 | PDisabUnderstand = 3 | PDisabUnderstand = 4 | PDisabWash = 3 | PDisabWash = 4 PDisabCat3 = 1. - -Value labels PDisabCat3 0 "without disability (category 3 criteria)" 1 "with disability (category 3 criteria)". - - -*creates a table of the percentage of type of assistance recieve by PDisabCat3 +Value labels + PDisabCat3 + 0 "without disability (category 3 criteria)" + 1 "with disability (category 3 criteria)". -*cash +* Creates a table of the percentage of type of assistance received by PDisabCat3. +* Cash. CROSSTABS /TABLES=HHAsstWFPRecCashYN1Y BY PDisabCat3 /FORMAT=AVALUE TABLES /CELLS=COLUMN /COUNT ROUND CELL. -*inkind - +* In-kind. CROSSTABS /TABLES=HHAsstWFPRecInKindYN1Y BY PDisabCat3 /FORMAT=AVALUE TABLES /CELLS=COLUMN /COUNT ROUND CELL. -*capacity building - +* Capacity building. CROSSTABS /TABLES=HHAsstWFPRecCapBuildYN1Y BY PDisabCat3 /FORMAT=AVALUE TABLES /CELLS=COLUMN /COUNT ROUND CELL. - - - - - -DATASET ACTIVATE DataSet1. - +DATASET ACTIVATE DataSet1. \ No newline at end of file diff --git a/Indicators/Protection-CRF-CC1-4/pro-CC1-4_roster_tidyverse.R b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster_tidyverse.R similarity index 50% rename from Indicators/Protection-CRF-CC1-4/pro-CC1-4_roster_tidyverse.R rename to Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster_tidyverse.R index 8abd478..49766b6 100644 --- a/Indicators/Protection-CRF-CC1-4/pro-CC1-4_roster_tidyverse.R +++ b/Indicators/Protection-CRF-CC1-4/pro-CC-1-4_roster_tidyverse.R @@ -1,32 +1,53 @@ +#------------------------------------------------------------------------------ +# WFP Standardized Scripts +# Disability Status and Assistance Received (Roster) +#------------------------------------------------------------------------------ +# +# Note: This script is based on the assumption that the dataset has already +# been imported and includes variables related to disability status and +# assistance received. +# +# The following variables should have been defined before running this script: +# - TechnicalAdd_submodule/HHAsstWFPRecCashYN1Y +# - TechnicalAdd_submodule/HHAsstWFPRecInKindYN1Y +# - TechnicalAdd_submodule/HHAsstWFPRecCapBuildYN1Y +# - Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers +#------------------------------------------------------------------------------ + library(tidyverse) library(labelled) library(expss) -#add sample data +# Add sample data data <- read_csv("GitHub/RAMResourcesScripts/Static/PRO_WG_Sample_Survey/RosterMethod/Demographic_module_DisabilityHHMemb_submodule_RepeatDisabHHMembers.csv") data2 <- read_csv("GitHub/RAMResourcesScripts/Static/PRO_WG_Sample_Survey/RosterMethod/data.csv") -#can only download repeat csv data as zip file from moda with group names - will update this code to remove group names -#rename to remove group names -data2 <- data2 %>% rename(HHAsstWFPRecCashYN1Y = 'TechnicalAdd_submodule/HHAsstWFPRecCashYN1Y') -data2 <- data2 %>% rename(HHAsstWFPRecInKindYN1Y = 'TechnicalAdd_submodule/HHAsstWFPRecInKindYN1Y') -data2 <- data2 %>% rename(HHAsstWFPRecCapBuildYN1Y = 'TechnicalAdd_submodule/HHAsstWFPRecCapBuildYN1Y') -data2 <- data2 %>% rename(index = '_index') - -data <- data %>% rename(PDisabAge = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabAge') -data <- data %>% rename(PDisabSex = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabSex') -data <- data %>% rename(PDisabSee = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabSee') -data <- data %>% rename(PDisabHear = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabHear') -data <- data %>% rename(PDisabWalk = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabWalk') -data <- data %>% rename(PDisabRemember = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabRemember') -data <- data %>% rename(PDisabUnderstand = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabUnderstand') -data <- data %>% rename(PDisabWash = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabWash') -data <- data %>% rename(index = '_parent_index') - -#join dataset "data" & "data2" +# Rename to remove group names +data2 <- data2 %>% + rename( + HHAsstWFPRecCashYN1Y = 'TechnicalAdd_submodule/HHAsstWFPRecCashYN1Y', + HHAsstWFPRecInKindYN1Y = 'TechnicalAdd_submodule/HHAsstWFPRecInKindYN1Y', + HHAsstWFPRecCapBuildYN1Y = 'TechnicalAdd_submodule/HHAsstWFPRecCapBuildYN1Y', + index = '_index' + ) + +data <- data %>% + rename( + PDisabAge = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabAge', + PDisabSex = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabSex', + PDisabSee = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabSee', + PDisabHear = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabHear', + PDisabWalk = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabWalk', + PDisabRemember = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabRemember', + PDisabUnderstand = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabUnderstand', + PDisabWash = 'Demographic_module/DisabilityHHMemb_submodule/RepeatDisabHHMembers/PDisabWash', + index = '_parent_index' + ) + +# Join dataset "data" & "data2" data <- data %>% left_join(data2, by = "index") -#assign variable and value labels +# Assign variable and value labels var_label(data$HHAsstWFPRecCashYN1Y) <- "Did your household receive cash-based WFP assistance in the last 12 months?" var_label(data$HHAsstWFPRecInKindYN1Y) <- "Did your household receive in-kind WFP assistance in the last 12 months?" var_label(data$HHAsstWFPRecCapBuildYN1Y) <- "Did you household receive WFP capacity building assistance in the last 12 months?" @@ -40,7 +61,6 @@ var_label(data$PDisabRemember) <- "Does ${PDisabName} have difficulty rememberin var_label(data$PDisabUnderstand) <- "Using your usual language, does ${PDisabName} have difficulty communicating, for example understanding or being understood? Would you say…" var_label(data$PDisabWash) <- "Does ${PDisabName} have difficulty with self-care, such as washing all over or dressing? Would you say…" - data <- data %>% mutate(across(c(HHAsstWFPRecCashYN1Y, HHAsstWFPRecInKindYN1Y, HHAsstWFPRecCapBuildYN1Y), ~labelled(., labels = c( "No" = 0, @@ -53,19 +73,19 @@ val_lab(data$PDisabSex) = num_lab(" ") data <- data %>% - mutate(across(c(PDisabSee,PDisabHear,PDisabWalk,PDisabRemember,PDisabUnderstand,PDisabWash), ~labelled(., labels = c( + mutate(across(c(PDisabSee, PDisabHear, PDisabWalk, PDisabRemember, PDisabUnderstand, PDisabWash), ~labelled(., labels = c( "No difficulty" = 1, "Some difficulty" = 2, "A lot of difficulty" = 3, "Cannot do at all" = 4, "Don't know" = 888, "Refuse" = 999 - )))) + )))) -#calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions. +# Calculate whether the respondent had "A lot of difficulty" or "Cannot do at all" for any of the 6 questions data <- data %>% mutate(PDisabCat3 = case_when( - between(PDisabSee,3,4) | between(PDisabHear,3,4) | between(PDisabWalk,3,4) | between(PDisabRemember,3,4) | between(PDisabUnderstand,3,4)| between(PDisabWash,3,4) ~ 1, - TRUE ~ 0 + between(PDisabSee, 3, 4) | between(PDisabHear, 3, 4) | between(PDisabWalk, 3, 4) | between(PDisabRemember, 3, 4) | between(PDisabUnderstand, 3, 4) | between(PDisabWash, 3, 4) ~ 1, + TRUE ~ 0 )) val_lab(data$PDisabCat3) = num_lab(" @@ -73,41 +93,39 @@ val_lab(data$PDisabCat3) = num_lab(" 1 with disability (category 3 criteria) ") +# Create tables of the weighted percentage of type of assistance received by PDisabCat3 -#creates a table of the weighted percentage of type of assistance recieve by PDisabCat3 -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - -#cash -HHAsstWFPRecCashYN1Y_table_wide <- data %>% group_by(PDisabCat3_lab = as_factor(PDisabCat3)) %>% +# Cash +HHAsstWFPRecCashYN1Y_table_wide <- data %>% + group_by(PDisabCat3_lab = as_factor(PDisabCat3)) %>% drop_na(HHAsstWFPRecCashYN1Y) %>% - count(HHAsstWFPRecCashYN1Y_lab = as_factor(HHAsstWFPRecCashYN1Y)) %>% # if weights are needed use instead the row below - #count(HHAsstWFPRecCashYN1Y_lab = as.character(HHAsstWFPRecCashYN1Y), wt = nameofweightvariable) + count(HHAsstWFPRecCashYN1Y_lab = as_factor(HHAsstWFPRecCashYN1Y)) %>% mutate(Percentage = 100 * n / sum(n)) %>% ungroup() %>% select(-n) %>% pivot_wider(names_from = HHAsstWFPRecCashYN1Y_lab, values_from = Percentage, values_fill = 0) -#inkind -HHAsstWFPRecInKindYN1Y_table_wide <- data %>% group_by(PDisabCat3_lab = as_factor(PDisabCat3)) %>% +# In-kind +HHAsstWFPRecInKindYN1Y_table_wide <- data %>% + group_by(PDisabCat3_lab = as_factor(PDisabCat3)) %>% drop_na(HHAsstWFPRecInKindYN1Y) %>% - count(HHAsstWFPRecInKindYN1Y_lab = as_factor(HHAsstWFPRecInKindYN1Y)) %>% # if weights are needed use instead the row below - #count(HHAsstWFPRecInKindYN1Y_lab = as.character(HHAsstWFPRecInKindYN1Y), wt = nameofweightvariable) + count(HHAsstWFPRecInKindYN1Y_lab = as_factor(HHAsstWFPRecInKindYN1Y)) %>% mutate(Percentage = 100 * n / sum(n)) %>% ungroup() %>% select(-n) %>% pivot_wider(names_from = HHAsstWFPRecInKindYN1Y_lab, values_from = Percentage, values_fill = 0) -#capacity building -HHAsstWFPRecCapBuildYN1Y_table_wide <- data %>% group_by(PDisabCat3_lab = as_factor(PDisabCat3)) %>% +# Capacity building +HHAsstWFPRecCapBuildYN1Y_table_wide <- data %>% + group_by(PDisabCat3_lab = as_factor(PDisabCat3)) %>% drop_na(HHAsstWFPRecCapBuildYN1Y) %>% - count(HHAsstWFPRecCapBuildYN1Y_lab = as_factor(HHAsstWFPRecCapBuildYN1Y)) %>% # if weights are needed use instead the row below - #count(HHAsstWFPRecCapBuildYN1Y_lab = as.character(HHAsstWFPRecCapBuildYN1Y), wt = nameofweightvariable) + count(HHAsstWFPRecCapBuildYN1Y_lab = as_factor(HHAsstWFPRecCapBuildYN1Y)) %>% mutate(Percentage = 100 * n / sum(n)) %>% ungroup() %>% select(-n) %>% - pivot_wider(names_from =HHAsstWFPRecCapBuildYN1Y_lab, + pivot_wider(names_from = HHAsstWFPRecCapBuildYN1Y_lab, values_from = Percentage, values_fill = 0) +# End of Scripts \ No newline at end of file