case-weight-helpers | R Documentation |
These functions can be used to do basic calculations with or without case weights.
get_case_weights(info, .data) averages(x, wts = NULL, na_rm = TRUE) medians(x, wts = NULL) variances(x, wts = NULL, na_rm = TRUE) correlations(x, wts = NULL, use = "everything", method = "pearson") covariances(x, wts = NULL, use = "everything", method = "pearson") pca_wts(x, wts = NULL) are_weights_used(wts, unsupervised = FALSE)
info |
A data frame from the |
.data |
The training data |
x |
A numeric vector or a data frame |
wts |
A vector of case weights |
na_rm |
A logical value indicating whether |
use |
Used by |
method |
Used by |
unsupervised |
Can the step handle unsupervised weights |
get_case_weights()
is designed for developers of recipe steps, to return
a column with the role of "case weight" as a vector.
For the other functions, rows with missing case weights are removed from calculations.
For averages()
and variances()
, missing values in the data (not the
case weights) only affect the calculations for those rows. For
correlations()
, the correlation matrix computation first removes rows
with any missing values (equal to the "complete.obs" strategy in
stats::cor()
).
are_weights_used()
is designed for developers of recipe steps and is used
inside print method to determine how printing should be done.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.