library(ramp.uganda)Region Pages
Use this to build, modify, or reconstruct the region pages.
Each region (except Kampala) has a directory called
<regionname>_regionthe region’s landing page is called
<regionname>_region/<regionname>_region.qmd.Notes for each region are stored in “regionname/_notes_regionname.qmd.” Changes to these files are tracked in
github.A map with the average PfPR for the last year is created by…
The icons…
Notes
This was called to set up the notes. Since empty files don’t get backed up to github, this might need to be called again. It won’t overwrite any file contents.
for(i in 1:15){
rdir = region_dir$region_dir[i]
cmd = paste("touch ../", rdir,"/_notes_", rdir, ".qmd", sep="")
system(cmd)
} Update Regional Maps
Set the location of the pixelated regional maps
regional_maps_path = paste(my_box_path, "data/pfpr_estimates/monthly/pixelated_maps/0_Regional_Maps/", sep="")update_region_pfpr_map = function(i, debug=FALSE){
rname = region_dir$region_name[i]
source_file = paste(regional_maps_path, rname, "/yearly_avg_", rname, "_2025_pfpr.png", sep="")
if(debug==TRUE) print(source_file)
rdir = region_dir$region_dir[i]
local_file = paste("../", rdir, "/", rdir, "_map.png", sep="")
if(debug==TRUE) print(local_file)
file.copy(source_file, local_file, overwrite=TRUE)
return(invisible())
}update_region_pfpr_map(i, debug=TRUE)for(i in 1:15) update_region_pfpr_map(i)Update Regional Movies
update_region_movie = function(i, debug=FALSE){
rname = region_dir$region_name[i]
source_file = paste(regional_maps_path, rname, ".mp4", sep="")
if(debug==TRUE) print(source_file)
rdir = region_dir$region_dir[i]
local_file = paste("../", rdir, "/", rdir, "_movie.mp4", sep="")
if(debug==TRUE) print(local_file)
file.copy(source_file, local_file, overwrite=TRUE)
return(invisible())
}for(i in 1:15) update_region_movie(i)make_region
The function make_region creates the \(i^{th}\) regional page:
make_region = function(i){
rname = region_dir$region_fullname[i]
rname_snake = region_dir$region_dir[i]
qmd_file = paste("../", rname_snake, "/", rname_snake, ".qmd", sep="")
movie_path = "../movies/"
cat("---\n", file=qmd_file)
cat(paste("title: ", rname, "\n"), file=qmd_file, append=TRUE)
cat("format: html\n", file=qmd_file, append=TRUE)
cat("editor:\n", file=qmd_file, append=TRUE)
cat(" mode: source\n", file=qmd_file, append=TRUE)
cat("---\n", file=qmd_file, append=TRUE)
rname_short = region_dir$region_name[i]
ix = which(district_dir$in_region == rname_short)
N = length(ix)
for(j in ix[-N]){
dname = district_dir$district_name[j]
ddir = district_dir$dir[j]
cat(paste("\n [",dname,"](../",ddir,"/",ddir, ".qmd) | ", sep=""), file=qmd_file, append=TRUE)
}
j = ix[N]
dname = district_dir$district_name[j]
ddir = district_dir$dir[j]
cat(paste("\n [",dname,"](../",ddir,"/",ddir, ".qmd) \n\n", sep=""), file=qmd_file, append=TRUE)
cat("| | |\n", file=qmd_file, append=TRUE)
cat("| --- | --- |\n", file=qmd_file, append=TRUE)
cat(paste("|  |  |\n\n", sep=""), file=qmd_file, append=TRUE)
cat(": {tbl-colwidths=\"[66,33]\"}\n\n", file=qmd_file, append=TRUE)
cat(paste("[Movie](./", rname_snake, "_movie.mp4)\n\n", sep=""), file=qmd_file, append=TRUE)
cat(paste("\n\n", sep=""), file=qmd_file, append=TRUE)
cat("{{", file=qmd_file, append=TRUE)
cat(paste("< include _notes_", rname_snake, ".qmd >}}\n", sep=""), file=qmd_file, append=TRUE)
}Update Region Pages
i=1
make_region(i)for(i in c(1:15)) make_region(i)