These functions can be used to do basic calculations with or without case weights.
get_case_weights(info, .data, call = rlang::caller_env())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)
A data frame from the info
argument within steps
The training data
The execution environment of a currently
running function, e.g. caller_env()
. The function will be
mentioned in error messages as the source of the error. See the
call
argument of abort()
for more information.
A numeric vector or a data frame
A vector of case weights
A logical value indicating whether NA
values should be removed during computations.
Used by correlations()
or covariances()
to pass argument to
cor()
or cov()
Used by correlations()
or covariances()
to pass argument to
cor()
or cov()
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.
developer_functions