R/help_check_weights.R

Defines functions help_check_weights

# Generated by fusen: do not edit by hand

#' Check Weights
#'
#' @param .weights weights 
#' @param .cols columns
#'
#' @return Error
#' @noRd
#' @examples
#' # help_check_weights()
help_check_weights <- function(.weights = NULL, .cols = NULL) {
  if (!is.null(.weights)) {
    nw_ <- sort(names(.weights))
    nc_ <- sort(.cols)
    lw_ <- length(nw_)
    lc_ <- length(nc_)
    
    if (lw_ == 0) stop(".weights must be a named vector", call. = FALSE)
    if (!lw_ == lc_) stop(".weights and .cols must have the same length", call. = FALSE)
    if (!all(nw_ == nc_)) stop(".weights and .cols must have the same names", call. = FALSE)
  }
}
MatthiasUckert/Rmatch documentation built on Jan. 3, 2022, 11:09 p.m.