Comprehensive Library for Working with Missing (NA) Values in Vectors

License is a comprehensive library for handling missing (NA) values. It has several goals:

  1. extend existing stats::na.*() functions,
  2. provide a collection for all functions for working with missing data together, and
  3. provide a consistent and intuitive interface.

In this package, there are methods for the detection, removal, replacement, –imputation–, recollection, etc. of missing values (NAs). This libraries focus is on vectors (atomics). For tidy/dplyr compliant methods operating on tables and lists, please use the tidyimpute package which depends on this package.



devtools::install_github( "decisionpatterns/")



Feature List

Upcoming features


x <- 1:3
x[2] <- NA_real_
na.replace(x, 2) 
na.replace(x, mean)     # error
na.replace(x, na.mean)  # Works  

Function List


Identification and Tests

Removal / Ommision / Exclusion

Replacement / Imputation

There are two types of imputation methods for plain vectors. They are distinguished by their replacement values.

Imputation by constant

In “constant” imputation methods, missing values are replaced by an a priori selected constant value. No calculation are performed to derive replacement values and all missing value assume the same transformied value.

Imputation by function

In functional imputation, the value is calculated from the vector containing the missing value(s) – and only that vector. Missing values may impute to different values. Replacement values may (or may not) be affected by the ording of the vector.

Cummatative functions

Commutative functions provide the same result irregarless of the ordering of the input vectors. Therefore, these functions do not depend on the ordering of elements of the input vector.

(When imputing in a table, imputation by function is also called column-based imputation since replacement values derive from the single column. Table-based imputation is found in the tidyimpute package.)

** Non-commulative functions **s

General Imputation

See Also

A number of other packages have methods for working with missing values and/or imputation. Here is a short, incomplete and growing list:

mitools provides tools for multiple imputation, mice provides multivariate imputation by chained equations mvnmle provides ML estimation for multivariate normal data with missing values, mix provides multiple imputation for mixed categorical and continuous data. pan provides multiple imputation for missing panel data. VIM provides methods for the visualisation as well as imputation of missing data. aregImpute() and transcan() from Hmisc provide further imputation methods. monomvn deals with estimation models where the missing data pattern is monotone.