score_custom: Score a Variable With a User-Defined Function

View source: R/scoring.R

score_customR Documentation

Score a Variable With a User-Defined Function

Description

Applies an arbitrary user-defined scoring function to a numeric vector. The function must accept a numeric vector and return a numeric vector of the same length with values in [0, 1].

Usage

score_custom(x, FUN, ...)

Arguments

x

Numeric vector of raw variable values.

FUN

A function with signature function(x) that returns numeric scores in [0, 1].

...

Additional arguments passed to FUN.

Value

Numeric vector of scores in [0, 1].

Examples

# Log-linear scoring for a skewed variable
mbc <- c(30, 80, 200, 400, 600)
score_custom(mbc, FUN = function(x) {
  s <- (log(x) - log(min(x))) / (log(max(x)) - log(min(x)))
  pmin(pmax(s, 0), 1)
})


SQIpro documentation built on April 20, 2026, 5:06 p.m.