#' Admission variable renamer
#'
#' @param x data frame of programmatic TB admission data which
#' has been cleaned with tbcleanr::adm_data_cleanr() and additional
#' variables generated using tbgeneratr::adm_generator()
#' @return data frame with standardised names for variables relevent
#' for the tbreportr package
#' @importFrom assertthat assert_that
#' @seealso \code{\link{tbreportr}}
#' @author Jay Achar
#'
#' @export
#'
adm_var_renamer.epiinfo <- function(x) {
# Define variables in df to change
original_names <- c("APID",
"SEX",
"REGRP",
"HIV",
"STARTTRE",
"DATEDEAT",
"DIPRO")
# Check variables are all present in data frame
assert_that(all(original_names %in% names(x)))
# Define new names
new_names <- c("unique_id",
"gender",
"reg_group",
"hiv_status",
"start_dt",
"death_dt",
"recorded_dst")
assert_that(length(original_names) == length(new_names))
# find positions of original names
position <- match(original_names, names(x))
# Change selected variable names
names(x)[position] <- new_names
x
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.