R/wtcalc_unit.R

Defines functions wtcalc.unit

Documented in wtcalc.unit

#' @rdname internal_desc
#' @export
wtcalc.unit <- function(wtLUT, strvar, unit, unitvar, acrevar){
  ## DESCRIPTION: Calculates weights (proportions) of strata by estimation unit

  wtUnit <- wtLUT[wtLUT[,unitvar] %in% unit,]
  strnamesUnit <- unique(wtUnit[,strvar])
  stracres <- tapply(wtUnit[,acrevar], wtUnit[,strvar], sum)
  stracres[!(levels(strnamesUnit) %in% strnamesUnit)] <- 0
  stracres/sum(stracres)
}

Try the FIESTAutils package in your browser

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

FIESTAutils documentation built on May 29, 2024, 4:06 a.m.