| impute-commutative {na.tools} | R Documentation |
Imputation by Cummutative Functions Impute using replacement values calculated from a univariate, cummuative function.
Description
Imputation by Cummutative Functions
Impute using replacement values calculated from a univariate, cummuative function.
na.median imputes with the median value of x. The median is only valid
for numeric or logical values.
Usage
na.max(.x, ...)
na.min(.x, ...)
na.mean(.x, ...)
na.median(.x, ...)
na.quantile(.x, ...)
na.mode(.x, ...)
na.most_freq(.x, ...)
Arguments
.x |
vector in which |
... |
additional arguments passed to lower-level summary functions. |
Details
This collection of functions calculates a replacement value using an
unvariate function where the order of values in x do not matter,
i.e. commutative.
na.max and na.min replace missing values (NA) with the maximum or
minimum of non-missing values x.
( Internally: base::max(..., na.rm=TRUE) and base::min(..., na.rm=TRUE).
... has no affect.
na.mean replaces NA values with the mean of x. Internally,
mean(x, na.rm=TRUE, ... ) is used. If mean cannot be calculated (e.g. x
isn't numeric) then x is returned with a warning.
na.quantile imputes with a quantile. The quantile is specified by a
probs argument that is passed to stats::quantile(). If probs can be
a scalar value in which all values are replaced by that quantile or a vector
of length(.x) values which replaces the missing values of x with the
probs. The ability to provide a vector may be deprecated in the future.
na.mode replaces all NA with the most frequently occuring value. In
the event of ties, the value encounter first in .x is used.
na.most_freq is an alias for na.mode.
Value
A vector of class(x) and length(x) in which missing values (NA) have
been replaced the result of a function call:
fun(x, ...)
See Also
-
na.replace()- used internally by these functions
Examples
na.median( c(1,2,NA_real_,3) )
na.quantile( c(1,2,NA_real_,3), prob=0.4 )
na.mode( c(1,1,NA,4) )
na.mode( c(1,1,4,4,NA) )