Impute.numeric {COINr}R Documentation

Impute a numeric vector


Imputes missing values in a numeric vector using a function f_i. This function should return a vector identical to x except for NA values, which can be replaced. The function f_i is not required to replace all NA values.


## S3 method for class 'numeric'
Impute(x, f_i = NULL, f_i_para = NULL, ...)



A numeric vector, possibly with NA values to be imputed.


A function that imputes missing values in a numeric vector. See description and details.


Optional further arguments to be passed to f_i()


arguments passed to or from other methods.


This calls the function f_i(), with optionally further arguments f_i_para, to impute any missing values found in x. By default, f_i = "i_mean()", which simply imputes NAs with the mean of the non-NA values in x.

You could also use one of the imputation functions directly (such as i_mean()). However, this function offers a few extra advantages, such as checking the input and output formats, and making sure the resulting imputed vector agrees with the input. It will also skip imputation entirely if there are no NAs at all.


An imputed numeric vector of the same length of x.


# a vector with a missing value
x <- 1:10
x[3] <- NA

# impute using median
# this calls COINr's i_median() function
Impute(x, f_i = "i_median")

[Package COINr version 1.1.7 Index]