Skip to content

Commit

Permalink
Updates to reporting documents and small edits to related scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowanmWHO committed Oct 3, 2024
1 parent bfcff9a commit 3680197
Show file tree
Hide file tree
Showing 23 changed files with 689 additions and 171 deletions.
2 changes: 1 addition & 1 deletion global.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ library(flextable)
library(officer)
library(ggpubr)
library(EpiReport)
library(xlsx)
#library(xlsx)
library(zscorer)
library(Hmisc)
library(survey)
Expand Down
8 changes: 5 additions & 3 deletions scripts/10_sample_description.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###Sample Description
bks = c('country',paste0('bk',1:12))
bks = c('country',paste0('bk',1:13))
original_raw_data = original_data

###
Expand All @@ -20,7 +20,8 @@ samp_desc = c(site_name,
paste0(formatC(round(100*(nrow(original_raw_data)/sum(long_school_sample$cenrol, na.rm = T)),1),format = 'f', digits = 1),'%'),' = ',
paste0(formatC(round(100*(sum(sample_schools$school_part==1, na.rm = T)/sum(sample_schools$school_part==1|sample_schools$school_part==0, na.rm = T))*
(nrow(original_raw_data)/sum(long_school_sample$cenrol, na.rm = T)),1),format = 'f', digits = 1),'%')),
paste0(levels(data$DE_GRADE)[1],' - ',levels(data$DE_GRADE)[length(levels(data$DE_GRADE))], ' in ',site_name))
paste0(levels(data$DE_GRADE)[1],' - ',levels(data$DE_GRADE)[length(levels(data$DE_GRADE))]),
paste0(site_name))
##
if (language == 'FRENCH'){
samp_desc = gsub('\\.',',',samp_desc)
Expand All @@ -46,7 +47,8 @@ if(weighted_reporting=='Yes'){
paste0(formatC(round(100*(nrow(original_raw_data)/sum(long_school_sample$cenrol, na.rm = T)),1),format = 'f', digits = 1),'%'),' = ',
paste0(formatC(round(100*(sum(sample_schools$school_part==1, na.rm = T)/sum(sample_schools$school_part==1|sample_schools$school_part==0, na.rm = T))*
(nrow(original_raw_data)/sum(long_school_sample$cenrol, na.rm = T)),1),format = 'f', digits = 1),'%')),
paste0(levels(data$DE_GRADE)[1],' - ',levels(data$DE_GRADE)[length(levels(data$DE_GRADE))], ' in ',site_name))
paste0(levels(data$DE_GRADE)[1],' - ',levels(data$DE_GRADE)[length(levels(data$DE_GRADE))]),
paste0(site_name))

if (language == 'FRENCH'){
samp_desc = gsub('\\.',',',samp_desc)
Expand Down
4 changes: 2 additions & 2 deletions scripts/11_school_sampling.R
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ if(double_draw == 'Yes')
i = NULL
for(i in 1:nrow(final_sample))
{
doc = read_docx(paste0(getwd(),'/templates/template_double_draw.docx'))
doc = read_docx(paste0(getwd(),'/templates/',sample_language,'/template_double_draw.docx'))
all_outputs = c(site_name,as.character(final_sample[i,'school']),
as.character(final_sample[i,'Field_ID']),as.character(final_sample[i,'GSHS']),
as.character(final_sample[i,'GYTS']),
Expand All @@ -363,7 +363,7 @@ if(double_draw == 'Yes')
i = NULL
for(i in 1:nrow(final_sample))
{
doc = read_docx(paste0(getwd(),'/templates/template_single_draw.docx'))
doc = read_docx(paste0(getwd(),'/templates/',sample_language,'/template_single_draw.docx'))
all_outputs = c(site_name,as.character(final_sample[i,'school']),
as.character(final_sample[i,'Field_ID']),
as.character(final_sample[i,'classes']),
Expand Down
8 changes: 4 additions & 4 deletions scripts/9_factsheet.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ doc = headers_replace_text_at_bkm(doc,"year",survey_year)
#
if(is_this_census == 'No')
{
additional_text = c(paste0(survey_year,' ',site_name),
additional_text = c(survey_year,
paste0(levels(data$DE_GRADE)[1],' - ',levels(data$DE_GRADE)[length(levels(data$DE_GRADE))]),
paste0(levels(data$DE_GRADE)[1],' - ',levels(data$DE_GRADE)[length(levels(data$DE_GRADE))]),
site_name,
Expand All @@ -163,12 +163,12 @@ additional_text = c(paste0(survey_year,' ',site_name),
paste0(formatC(round(100*(sum(long_school_sample$stpart,na.rm = T)/sum(long_school_sample$cenrol, na.rm = T)),1),format = 'f', digits = 1),'%'),
paste0(formatC(round(100*(sum(sample_schools$school_part==1, na.rm = T)/sum(sample_schools$school_part==1|sample_schools$school_part==0, na.rm = T))*(sum(long_school_sample$stpart,na.rm = T)/sum(long_school_sample$cenrol, na.rm = T)),1),format = 'f', digits = 1),'%'),
nrow(data),
site_name)
site_name,site_name)
bmks = paste0('bmk', 1:length(additional_text))
#
eval(parse(text=paste0('doc = body_replace_text_at_bkm(doc,"', bmks,'","', additional_text,'")', sep='\n')))
} else{
additional_text = c(paste0(survey_year,' ',site_name),
additional_text = c(survey_year,
paste0(levels(data$DE_GRADE)[1],' - ',levels(data$DE_GRADE)[length(levels(data$DE_GRADE))]),
paste0(levels(data$DE_GRADE)[1],' - ',levels(data$DE_GRADE)[length(levels(data$DE_GRADE))]),
site_name,
Expand All @@ -179,7 +179,7 @@ eval(parse(text=paste0('doc = body_replace_text_at_bkm(doc,"', bmks,'","', addit
paste0(formatC(round(100*(sum(long_school_sample$stpart,na.rm = T)/sum(long_school_sample$cenrol, na.rm = T)),1),format = 'f', digits = 1),'%'),
paste0(formatC(round(100*(sum(sample_schools$school_part==1, na.rm = T)/sum(sample_schools$school_part==1|sample_schools$school_part==0, na.rm = T))*(sum(long_school_sample$stpart,na.rm = T)/sum(long_school_sample$cenrol, na.rm = T)),1),format = 'f', digits = 1),'%'),
nrow(data),
site_name)
site_name,site_name)
bmks = paste0('bmk', 1:length(additional_text))

eval(parse(text=paste0('doc = body_replace_text_at_bkm(doc,"', bmks,'","', additional_text,'")', sep='\n')))
Expand Down
Loading

0 comments on commit 3680197

Please sign in to comment.