R/prepLabels.R

Defines functions prepLabels

Documented in prepLabels

#' Generate column names for percentage table
#'
#' Formats column names to be used with a percentage table
#' @param .table Data table
#' @param .var Column name for variable of interest
#' @param .admbounds String specifying administrative codes
#' @return List of formatted column names
#' @export
#' @examples
#' prepLabels(data[['building']], 'dm_grade', 'ward')

prepLabels <- function(.table, .var, .admbounds) {
  codes <- sort(unique(.table[[.var]]),na.last=TRUE)
  var_names <- sapply(codes, function(x) paste(.var,x,sep=""))
  out_names <- c(.admbounds,var_names)
  return(out_names)
}
bradleyswilson/hrrp documentation built on May 28, 2019, 7:13 p.m.