R/get_weights.R

Defines functions get_weights

Documented in get_weights

# Generated by fusen: do not edit by hand

#' Get Weights
#' 
#' Description
#' 
#' @param .tab 
#' A dataframe (either the source or target dataframe)
#' @param .cols_match 
#' A character vector of columns to perform fuzzy matching.  
#'
#' @return A numeric vector
#' 
#' @export
#' @examples
#' get_weights(table_source, c("name", "city", "address"))
get_weights <- function(.tab, .cols_match) {
  . <- NULL
  purrr::map_dbl(
    .x = stats::setNames(.cols_match, .cols_match), 
    .f = ~ mean(uniqueness_vec(.tab[[.x]]), na.rm = TRUE)
    ) %>% `/`(sum(., na.rm = TRUE))
}
MatthiasUckert/Rmatch documentation built on Jan. 3, 2022, 11:09 p.m.