colMeans_if calculates the mean of every column in a numeric or
logical matrix conditional on the frequency of observed data. If the
frequency of observed values in that column is less than (or equal to) that
ov.min, then NA is returned for that row.
numeric or logical matrix. If not a matrix, it will be coerced to one.
minimum frequency of observed values required per column. If
logical vector of length 1 specifying whether
logical vector of length 1 specifying whether the mean
should be calculated if the frequency of observed values in a column is
exactly equal to
Conceptually this function does:
apply(X = x, MARGIN = 2, FUN =
mean_if, ov.min = ov.min, prop = prop, inclusive = inclusive). But for
computational efficiency purposes it does not because then the missing values
conditioning would not be vectorized. Instead, it uses
then inserts NAs for columns that have too few observed values.
numeric vector of length =
ncol(x) with names =
colnames(x) providing the mean of each column or NA depending on the
frequency of observed values.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.