R/bootClassic.R

Defines functions bootClassic

Documented in bootClassic

################################################################################
#
#' bootClassic
#'
#' Simple proportion statistics function for bootstrap estimation
#'
#' @param x A data frame with \code{primary sampling unit (PSU)} in column named
#'   \code{psu} and with data column/s containing the binary variable/s (0/1) of
#'   interest with column names corresponding to \code{params} values
#' @param params A vector of column names corresponding to the binary variables
#'   of interest contained in \code{x}
#' @return A numeric vector of the mean of each binary variable of interest with
#'   length equal to \code{length(params)}
#' @examples
#'
#' # Example call to bootClassic function
#'
#' meanResults <- bootClassic(x = indicatorsHH,
#'                            params = "anc1")
#'
bootClassic <- function(x, params) {
  result <- vector(mode = "numeric", length = length(params))
  for(i in 1:length(params)) {
    result[i]  <- mean(x[[params[i]]], na.rm = TRUE)
  }
  return(result)
}

Try the bbw package in your browser

Any scripts or data that you put into this service are public.

bbw documentation built on Jan. 20, 2018, 9:11 a.m.