Impute using replacement values calculated from a univariate, cummuative function.
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.
na.max(.x, ...)na.min(.x, ...)
na.mean(.x, ...)
na.median(.x, ...)
na.quantile(.x, ...)
na.mode(.x, ...)
na.most_freq(.x, ...)
vector in which NA values are to be replaced. The ordering of x
does not matter.
additional arguments passed to lower-level summary functions.
A vector of class(x) and length(x) in which missing values (NA) have
been replaced the result of a function call: $$ fun(x, ...) $$
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.
na.replace() - used internally by these functions
# NOT RUN {
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) )
# }
Run the code above in your browser using DataLab