This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(readr) | |
library(tidyr) | |
library(forcats) | |
library(haven) | |
library(survey) | |
phia_path <- "~/Data/household surveys/PHIA/datasets" | |
cmr2017phia <- rdhs::read_zipdata(file.path(phia_path, "CMR/datasets/302 CAMPHIA 2017-2018 Adult Biomarker Dataset (DTA).zip")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(readr) | |
library(tidyr) | |
library(forcats) | |
library(haven) | |
library(survey) | |
## devtools::install_github("jeffeaton/svyincid") | |
library(svyincid) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(brio) | |
library(readr) | |
library(first90) # remotes::install_github("mrc-ide/first90release") | |
#' ## Define functions | |
get_pjnz_shiny90_filename <- function (pjnz) { | |
files <- utils::unzip(pjnz, list = TRUE)$Name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Requires library eppasm | |
dpsub <- function(dp, tag, rows, cols, tagcol = 1) { | |
dp[which(dp[, tagcol] == tag) + rows, cols] | |
} | |
read_frr_fit_input <- function(pjnz) { | |
dp <- eppasm::read_dp(pjnz) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(xml2) | |
library(epp) | |
eppd_overwrite_matrix <- function (xm, mat) { | |
if (!xml_attr(xm, "class") %in% c("[D", "[I")) | |
stop("Tried to invoke .parse_matrix() on array node not of class '[D' or '[I'.") | |
m_rows <- as.integer(xml_attr(xm, "length")) | |
stopifnot(nrow(mat) == m_rows) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' This function saves an updated data pack export CSV in the same directory as | |
#' the Naomi output package file | |
#' | |
#' Example: | |
#' | |
#' file <- "~/Downloads/MWI_20210308-090536_naomi_spectrum_digest.zip" ## !! REPLACE HERE | |
#' adjust_datapack_export2021(file) | |
#' | |
adjust_datapack_export2021 <- function(naomi_output_package) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(pdftools) | |
library(readr) | |
library(stringr) | |
library(tidyr) | |
url <- "http://www.nsomalawi.mw/images/stories/data_on_line/demography/census_2018/Thematic_Reports/Population%20Projections%202018-2050.pdf" | |
file <- tempfile(fileext = ".pdf") | |
download.file(url, file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' This script is an example of the function subset_output_package() to load, | |
#' subset, and resave the Naomi output package. | |
#' | |
#' The arguments to the function are: | |
#' | |
#' * path: file path to the output package. | |
#' * output_path: file path to save the new subsetted package (end in .zip). | |
#' * area_id: vector of area_ids to keep or drop. | |
#' * area_level: vector of area_levels to keep or drop. | |
#' * sex: vector of sexes to keep or drop. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Export proportion aware by five year age group from Shiny90 | |
#' | |
#' Export estimates for proportion aware of status from a Shiny90 | |
#' output file to five-year age groups 15-19 to 50+. | |
#' | |
#' @param shiny90_path file path to .shiny90 digest file. | |
#' @param out_path output path to save CSV of proportion aware. | |
#' @param year year(s) to generate estimates; an integer or a vector of integers. | |
#' | |
#' @return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Export proportion aware by five year age group from Shiny90 | |
#' | |
#' Export estimates for proportion aware of status from a Shiny90 | |
#' output file to five-year age groups 15-19 to 50+. | |
#' | |
#' @param shiny90_path file path to .shiny90 digest file. | |
#' @param out_path output path to save CSV of proportion aware. | |
#' @param year year(s) to generate estimates; an integer or a vector of integers. | |
#' | |
#' @return |
NewerOlder