| case_weights | R Documentation |
Computes case weights adding to one for response variables of these types:
numeric binomial (1 and 0).
logical (TRUE and FALSE): converted to numeric internally.
categorical (character or factor)
Values NA, Inf, -Inf, and NaN are invalid for numeric and logical variables and will result in errors. For categorical variables, these are converted to their respective categories ("NA", "Inf", "-Inf", and "NaN") with their assigned case weights.
All returned weights sum to one.
case_weights(x = NULL, ...)
x |
(required, integer, character, or factor vector) Values of a binomial, categorical, or factor variable. Default: NULL |
... |
(optional) Internal args (e.g. |
numeric vector: case weights
Other modelling_tools:
model_formula(),
score_auc(),
score_cramer(),
score_r2()
#numeric vector
y <- case_weights(
x = c(0, 0, 1, 1)
)
#logical vector
y <- case_weights(
x = c(TRUE, TRUE, FALSE, FALSE)
)
#character vector
y <- case_weights(
x = c("a", "a", "b", "c")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.