diff --git a/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.do b/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.do new file mode 100644 index 0000000..7658d8b --- /dev/null +++ b/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.do @@ -0,0 +1,23 @@ +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* NUT7 Coverage Indicator +*------------------------------------------------------------------------------* + +* Note: This syntax file processes the NUT7 coverage indicator by assessing +* participant enrollment in a specified nutrition program. + +* Can only download repeat CSV data as a zip file from MODA with group names. +* Will update this code to remove group names. + +* Rename to remove group names. +rename Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgPartic PNutProgPartic_yn + +* Define variable and value labels. +label variable PNutProgPartic_yn "Is participant enrolled in the ((insert name/description of program, to be adapted locally)) programme?" +label define PNutProgPartic_yn_label 0 "No" 1 "Yes" +label values PNutProgPartic_yn PNutProgPartic_yn_label + +* Frequency table for PNutProgPartic_yn. +tabulate PNutProgPartic_yn + +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.py b/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.py new file mode 100644 index 0000000..f3e0a7e --- /dev/null +++ b/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.py @@ -0,0 +1,29 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# NUT7 Coverage Indicator +#------------------------------------------------------------------------------# + +# Note: This script processes the NUT7 coverage indicator by assessing participant +# enrollment in a specified nutrition program. + +import pandas as pd +import numpy as np + +# Add sample data. +#data = pd.read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_CRF_7_coverage_Sample_Survey/Nutrition_module_NutProg_submodule_RepeatNutProg.csv") + +# Can only download repeat CSV data as a zip file from MODA with group names. +# Rename to remove group names. +data = data.rename(columns={'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgPartic_yn': 'PNutProgPartic_yn'}) + +# Assign variable and value labels. +data['PNutProgPartic_yn'] = data['PNutProgPartic_yn'].astype('category') +data['PNutProgPartic_yn'].cat.categories = ["No", "Yes"] +data['PNutProgPartic_yn'].cat.set_categories([0, 1], rename=True, inplace=True) + +# Create a table of the weighted percentage of NutProgPartic_yn. +nut_prog_partic_yn_table = data['PNutProgPartic_yn'].value_counts(normalize=True).reset_index() +nut_prog_partic_yn_table.columns = ['PNutProgPartic_yn', 'Percentage'] +nut_prog_partic_yn_table['Percentage'] = nut_prog_partic_yn_table['Percentage'] * 100 + +# End of Scripts. \ No newline at end of file diff --git a/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.sps b/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.sps index f1bdf10..01f09b1 100644 --- a/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.sps +++ b/Indicators/Nutrition-CRF-7-coverage/nut7_coverage.sps @@ -1,15 +1,25 @@ -* Encoding: UTF-8. +******************************************************************************** +* WFP Standardized Scripts +* NUT7 Coverage Indicator +******************************************************************************** -*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 +* Note: This syntax file processes the NUT7 coverage indicator by assessing +* participant enrollment in a specified nutrition program. + +* Define variable and value labels. + +* Can only download repeat CSV data as a zip file from MODA with group names. +* Will update this code to remove group names. RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgPartic = PNutProgPartic_yn). -* define variable and value labels +* Define variable and value labels. -Variable labels PNutProgPartic_yn ‘Is participant enrolled in the ((insert name/description of program, to be adapted locally)) programme?’. +VARIABLE LABELS PNutProgPartic_yn 'Is participant enrolled in the ((insert name/description of program, to be adapted locally)) programme?'. -Value labels PNutProgPartic_ynNutProgPartic_yn 1 'Yes' 0 'No '. +VALUE LABELS PNutProgPartic_yn 1 'Yes' 0 'No'. -freq PNutProgPartic_yn. +* Frequency table for PNutProgPartic_yn. +FREQUENCIES VARIABLES=PNutProgPartic_yn. +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Nutrition-CRF-7-coverage/nut7_coverage_tidyverse.R b/Indicators/Nutrition-CRF-7-coverage/nut7_coverage_tidyverse.R index 1582df1..abc3c00 100644 --- a/Indicators/Nutrition-CRF-7-coverage/nut7_coverage_tidyverse.R +++ b/Indicators/Nutrition-CRF-7-coverage/nut7_coverage_tidyverse.R @@ -1,34 +1,38 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# NUT7 Coverage Indicator +#------------------------------------------------------------------------------# + +# Note: This script processes the NUT7 coverage indicator by assessing participant +# enrollment in a specified nutrition program. + library(tidyverse) library(labelled) library(expss) -#add sample data -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_CRF_7_coverage_Sample_Survey/Nutrition_module_NutProg_submodule_RepeatNutProg.csv") +# Add sample data. +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_CRF_7_coverage_Sample_Survey/Nutrition_module_NutProg_submodule_RepeatNutProg.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 +# Can only download repeat CSV data as a zip file from MODA with group names. +# Rename to remove group names. data <- data %>% rename(PNutProgPartic_yn = 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgPartic_yn') - -#assign variable and value labels -var_label(data$PNutProgPartic_yn) <- "Is participant enrolled in the ((insert name/description of program, to be adapted locally)) programme?" +# Assign variable and value labels. +var_label(data$PNutProgPartic_yn) <- "Is participant enrolled in the ((insert name/description of program, to be adapted locally)) programme?" val_lab(data$PNutProgPartic_yn) = num_lab(" 0 No 1 Yes ") - -#creates a table of the weighted percentage of NutProgPartic_yn by -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - - -NutProgPartic_yn_table_wide <- data %>% +# Create a table of the weighted percentage of NutProgPartic_yn. +NutProgPartic_yn_table_wide <- data %>% drop_na(PNutProgPartic_yn) %>% - count(PNutProgPartic_yn_lab = as.character(PNutProgPartic_yn)) %>% # if weights are needed use instead the row below - #count(PNutProgPartic_yn_lab = as.character(PNutProgPartic_yn), wt = nameofweightvariable) + count(PNutProgPartic_yn_lab = as.character(PNutProgPartic_yn)) %>% + # Use the line below if weights are needed. + # count(PNutProgPartic_yn_lab = as.character(PNutProgPartic_yn), wt = nameofweightvariable) mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = PNutProgPartic_yn_lab, - values_from = Percentage, - values_fill = 0) \ No newline at end of file + ungroup() %>% + select(-n) %>% + pivot_wider(names_from = PNutProgPartic_yn_lab, values_from = Percentage, values_fill = 0) + +# End of Scripts. \ No newline at end of file diff --git a/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.do b/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.do index e3e7bde..30420d8 100644 --- a/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.do +++ b/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.do @@ -1,29 +1,41 @@ -*add sample data -import delimited using "../../Static/Nut_CRF_8_adherence_Sample_Survey/Nutrition_module_NutProg_submodule_RepeatNutProg.csv" +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* NUT8 Adherence Indicator +*------------------------------------------------------------------------------* +* Note: This syntax file processes the NUT8 adherence indicator by assessing +* whether participants received an adequate number of distributions as per +* program requirements. -rename (v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13) (PNutProgParticName PNutProgCard PNutProgShouldNbrCard PNutProgDidNbrCard PNutwhendate PNutProgShouldNbrNoCard PNutProgDidNbrNoCard PNutProgEntitlements PNoNutProgReason PNoNutProgReason_other PNoNutProgCardReason PNoNutProgCardReason_other) -*#assign variable labels +* Can only download repeat CSV data as a zip file from MODA with group names. +* Will update this code to remove group names. -label var PNutProgCard "May I see participant's program participation card?" -label var PNutProgShouldNbrCard "number of distributions entitled to - measured with participation card" -label var PNutProgDidNbrCard "number of distributions received - measured with participation card" -label var PNutProgShouldNbrNoCard "number of distributions entitled to - measured without participation card" -label var PNutProgDidNbrNoCard "number of distributions received - measured without participation card" -label define Yesno 1 "Yes" 0 "No" - -*#create variable which classifies if participant received 66% or more of planned distributions -gen NutProgRecAdequate=cond((PNutProgCard == 1 & ((PNutProgDidNbrCard / PNutProgShouldNbrCard) >= .66) == 1) | /// - (PNutProgCard == 0 & ((PNutProgDidNbrNoCard / PNutProgShouldNbrNoCard) >= .66) == 1),1,0) -label var NutProgRecAdequate "Participant recieved adequate number of distributions?" +* Add sample data. +*import delimited using "~/GitHub/RAMResourcesScripts/Static/Nut_CRF_8_adherence_Sample_Survey/Nutrition_module_NutProg_submodule_RepeatNutProg.csv" +* Rename to remove group names. +rename Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgCard PNutProgCard +rename Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgShouldN_A PNutProgShouldNbrCard +rename Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgDidNbrC PNutProgDidNbrCard +rename Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgShouldN PNutProgShouldNbrNoCard +rename Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgDidNbrN PNutProgDidNbrNoCard +* Define variable and value labels. +label variable PNutProgCard "May I see participant's program participation card?" +label variable PNutProgShouldNbrCard "Number of distributions entitled to - measured with participation card" +label variable PNutProgDidNbrCard "Number of distributions received - measured with participation card" +label variable PNutProgShouldNbrNoCard "Number of distributions entitled to - measured without participation card" +label variable PNutProgDidNbrNoCard "Number of distributions received - measured without participation card" +label define Yesno 1 "Yes" 0 "No" label values PNutProgCard NutProgRecAdequate Yesno -/* -#creates a table of the weighted percentage of NutProgRecAdequate by -#creating a temporary variable to display value labels -#and providing the option to use weights if needed -*/ -cap gen WeightHH=1 +* Create variable which classifies if participant received 66% or more of planned distributions. +gen NutProgRecAdequate = cond((PNutProgCard == 1 & ((PNutProgDidNbrCard / PNutProgShouldNbrCard) >= .66)) | /// + (PNutProgCard == 0 & ((PNutProgDidNbrNoCard / PNutProgShouldNbrNoCard) >= .66)), 1, 0) +label variable NutProgRecAdequate "Participant received adequate number of distributions?" + +* Create a table of the weighted percentage of NutProgRecAdequate. +cap gen WeightHH = 1 tabulate NutProgRecAdequate [aw=WeightHH] + +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.py b/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.py new file mode 100644 index 0000000..5ac0431 --- /dev/null +++ b/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.py @@ -0,0 +1,47 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# NUT8 Adherence Indicator +#------------------------------------------------------------------------------# + +# Note: This script processes the NUT8 adherence indicator by assessing +# whether participants received an adequate number of distributions as per +# program requirements. + +import pandas as pd +import numpy as np + +# Add sample data +#data = pd.read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_CRF_8_adherence_Sample_Survey/Nutrition_module_NutProg_submodule_RepeatNutProg.csv") + +# Can only download repeat CSV data as a zip file from MODA with group names. +# Rename to remove group names. +data = data.rename(columns={ + 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgCard': 'PNutProgCard', + 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgShouldNbrCard': 'PNutProgShouldNbrCard', + 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgDidNbrCard': 'PNutProgDidNbrCard', + 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgShouldNbrNoCard': 'PNutProgShouldNbrNoCard', + 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgDidNbrNoCard': 'PNutProgDidNbrNoCard' +}) + +# Assign variable and value labels. +data['PNutProgCard'] = data['PNutProgCard'].astype('category') +data['PNutProgCard'].cat.rename_categories({0: 'No', 1: 'Yes'}, inplace=True) + +# Create variable which classifies if participant received 66% or more of planned distributions. +data['NutProgRecAdequate'] = np.where( + (data['PNutProgCard'] == 'Yes') & ((data['PNutProgDidNbrCard'] / data['PNutProgShouldNbrCard']) >= 0.66) | + (data['PNutProgCard'] == 'No') & ((data['PNutProgDidNbrNoCard'] / data['PNutProgShouldNbrNoCard']) >= 0.66), + 1, 0 +) +data['NutProgRecAdequate'] = data['NutProgRecAdequate'].astype('category') +data['NutProgRecAdequate'].cat.rename_categories({0: 'No', 1: 'Yes'}, inplace=True) + +# Create a table of the weighted percentage of NutProgRecAdequate. +nutprog_table = data['NutProgRecAdequate'].value_counts(normalize=True).reset_index() +nutprog_table.columns = ['NutProgRecAdequate', 'Percentage'] +nutprog_table['Percentage'] *= 100 + +# Print the table. +print(nutprog_table) + +# End of Scripts. \ No newline at end of file diff --git a/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.sps b/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.sps index da6cb04..8422df0 100644 --- a/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.sps +++ b/Indicators/Nutrition-CRF-8-adherence/nut8_adherence.sps @@ -1,34 +1,42 @@ -* Encoding: UTF-8. +******************************************************************************** +* WFP Standardized Scripts +* NUT8 Adherence Indicator +******************************************************************************** -*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 truncates name +* Note: This syntax file processes the NUT8 adherence indicator by assessing +* whether participants received an adequate number of distributions as per +* program requirements. -RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgCard = PNutProgCard). -RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgShouldN_A = PNutProgShouldNbrCard). -RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgDidNbrC = PNutProgDidNbrCard). -RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgShouldN = PNutProgShouldNbrNoCard). -RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgDidNbrN = PNutProgDidNbrNoCard). - -* define variable and value labels +* Can only download repeat CSV data as a zip file from MODA with group names. +* Will update this code to remove group names. -Variable labels PNutProgCard "May I see participant's program participation card?". -Variable labels PNutProgShouldNbrCard 'number of distributions entitled to - measured with participation card'. -Variable labels PNutProgDidNbrCard 'number of distributions received - measured with participation card'. -Variable labels PNutProgShouldNbrNoCard 'number of distributions entitled to - measured without participation card'. -Variable labels PNutProgDidNbrNoCard 'number of distributions received - measured without participation card'. +* Rename to remove group names. +RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgCard = PNutProgCard). +RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgShouldN_A = PNutProgShouldNbrCard). +RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgDidNbrC = PNutProgDidNbrCard). +RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgShouldN = PNutProgShouldNbrNoCard). +RENAME VARIABLES (Nutrition_moduleNutProg_submoduleRepeatNutProgPNutProgDidNbrN = PNutProgDidNbrNoCard). -Value labels PNutProgCard 1 'Yes' 0 'No '. +* Define variable and value labels. +VARIABLE LABELS PNutProgCard "May I see participant's program participation card?". +VARIABLE LABELS PNutProgShouldNbrCard "Number of distributions entitled to - measured with participation card". +VARIABLE LABELS PNutProgDidNbrCard "Number of distributions received - measured with participation card". +VARIABLE LABELS PNutProgShouldNbrNoCard "Number of distributions entitled to - measured without participation card". +VARIABLE LABELS PNutProgDidNbrNoCard "Number of distributions received - measured without participation card". -*create variable which classifies if participant received 66% or more of planned distributions +VALUE LABELS PNutProgCard 1 'Yes' 0 'No'. -do if ((PNutProgCard = 1) & ((PNutProgDidNbrCard / PNutProgShouldNbrCard) >= .66)) OR ((PNutProgCard = 0) & ((PNutProgDidNbrNoCard / PNutProgShouldNbrNoCard) >= .66)) . -compute NutProgRecAdequate = 1. -Else. -Compute NutProgRecAdequate = 0. -End if. +* Create variable which classifies if participant received 66% or more of planned distributions. +DO IF ((PNutProgCard = 1) & ((PNutProgDidNbrCard / PNutProgShouldNbrCard) >= .66)) OR ((PNutProgCard = 0) & ((PNutProgDidNbrNoCard / PNutProgShouldNbrNoCard) >= .66)). + COMPUTE NutProgRecAdequate = 1. +ELSE. + COMPUTE NutProgRecAdequate = 0. +END IF. -Variable labels PNutProgDidNbrNoCard "Participant recieved adequate number of distributions?". -Value labels NutProgRecAdequate 1 'Yes' 0 'No '. +VARIABLE LABELS NutProgRecAdequate "Participant received adequate number of distributions?". +VALUE LABELS NutProgRecAdequate 1 'Yes' 0 'No'. -freq NutProgRecAdequate. +* Frequency table for NutProgRecAdequate. +FREQUENCIES VARIABLES=NutProgRecAdequate. +* End of Scripts. \ No newline at end of file diff --git a/Indicators/Nutrition-CRF-8-adherence/nut8_adherence_tidyverse.R b/Indicators/Nutrition-CRF-8-adherence/nut8_adherence_tidyverse.R index f7a4c47..426c326 100644 --- a/Indicators/Nutrition-CRF-8-adherence/nut8_adherence_tidyverse.R +++ b/Indicators/Nutrition-CRF-8-adherence/nut8_adherence_tidyverse.R @@ -1,12 +1,21 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# NUT8 Adherence Indicator +#------------------------------------------------------------------------------# + +# Note: This script processes the NUT8 adherence indicator by assessing +# whether participants received an adequate number of distributions as per +# program requirements. + library(tidyverse) library(labelled) library(expss) -#add sample data -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_CRF_8_adherence_Sample_Survey/Nutrition_module_NutProg_submodule_RepeatNutProg.csv") +# Add sample data. +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_CRF_8_adherence_Sample_Survey/Nutrition_module_NutProg_submodule_RepeatNutProg.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 +# Can only download repeat CSV data as a zip file from MODA with group names. +# Rename to remove group names. data <- data %>% rename(PNutProgCard = 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgCard', PNutProgShouldNbrCard = 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgShouldNbrCard', PNutProgDidNbrCard = 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgDidNbrCard', @@ -14,40 +23,39 @@ data <- data %>% rename(PNutProgCard = 'Nutrition_module/NutProg_submodule/Repea PNutProgDidNbrNoCard = 'Nutrition_module/NutProg_submodule/RepeatNutProg/PNutProgDidNbrNoCard' ) -#assign variable labels -var_label(data$PNutProgCard) <- "May I see participant's program participation card?" -var_label(data$PNutProgShouldNbrCard) <- "number of distributions entitled to - measured with participation card" -var_label(data$PNutProgDidNbrCard) <- "number of distributions received - measured with participation card" -var_label(data$PNutProgShouldNbrNoCard) <- "number of distributions entitled to - measured without participation card" -var_label(data$PNutProgDidNbrNoCard) <- "number of distributions received - measured without participation card" +# Assign variable and value labels. +var_label(data$PNutProgCard) <- "May I see participant's program participation card?" +var_label(data$PNutProgShouldNbrCard) <- "Number of distributions entitled to - measured with participation card" +var_label(data$PNutProgDidNbrCard) <- "Number of distributions received - measured with participation card" +var_label(data$PNutProgShouldNbrNoCard) <- "Number of distributions entitled to - measured without participation card" +var_label(data$PNutProgDidNbrNoCard) <- "Number of distributions received - measured without participation card" val_lab(data$PNutProgCard) = num_lab(" 0 No 1 Yes ") -#create variable which classifies if participant received 66% or more of planned distributions +# Create variable which classifies if participant received 66% or more of planned distributions. data <- data %>% mutate(NutProgRecAdequate = case_when( PNutProgCard == 1 & ((PNutProgDidNbrCard / PNutProgShouldNbrCard) >= .66) ~ 1, PNutProgCard == 0 & ((PNutProgDidNbrNoCard / PNutProgShouldNbrNoCard) >= .66) ~ 1, TRUE ~ 0 )) -var_label(data$NutProgRecAdequate) <- "Participant recieved adequate number of distributions?" +var_label(data$NutProgRecAdequate) <- "Participant received adequate number of distributions?" val_lab(data$NutProgRecAdequate) = num_lab(" 0 No 1 Yes ") -#creates a table of the weighted percentage of NutProgRecAdequate by -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - -NutProgRecAdequate_table_wide <- data %>% +# Create a table of the weighted percentage of NutProgRecAdequate. +NutProgRecAdequate_table_wide <- data %>% drop_na(NutProgRecAdequate) %>% - count(NutProgRecAdequate_lab = as.character(NutProgRecAdequate)) %>% # if weights are needed use instead the row below - #count(NutProgRecAdequate_lab = as.character(NutProgRecAdequate), wt = nameofweightvariable) + count(NutProgRecAdequate_lab = as.character(NutProgRecAdequate)) %>% + # Use the line below if weights are needed. + # count(NutProgRecAdequate_lab = as.character(NutProgRecAdequate), wt = nameofweightvariable) mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = NutProgRecAdequate_lab, - values_from = Percentage, - values_fill = 0) \ No newline at end of file + ungroup() %>% + select(-n) %>% + pivot_wider(names_from = NutProgRecAdequate_lab, values_from = Percentage, values_fill = 0) + +# End of Scripts. \ No newline at end of file