impute-commutative: Imputation by Cummutative Functions Impute using replacement...

Description Usage Arguments Details Value See Also Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13

Arguments

.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.

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

median()

Examples

1
2
3
4
5
6
  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) ) 

na.tools documentation built on June 26, 2018, 5:02 p.m.