| score_custom | R Documentation |
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].
score_custom(x, FUN, ...)
x |
Numeric vector of raw variable values. |
FUN |
A function with signature |
... |
Additional arguments passed to |
Numeric vector of scores in [0, 1].
# 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)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.