Learn R Programming

useful (version 1.2.6)

simple.impute.default: simple.impute.default

Description

Function for imputing a vector with missing data.

Usage

# S3 method for default
simple.impute(x, fun = median, ...)

Value

An object with the missing values imputed.

Arguments

x

A numeric or integer vector

fun

The function with which to fill in missing values

...

Further arguments

Author

Jared P. Lander

Details

Provides the ability to simply impute data based on a simple measure such as mean or median. For more robust imputation see the packages Amelia, mice or mi.

Examples

Run this code
theDF <- data.frame(A=1:10, B=1:10, C=1:10)
theDF[c(1, 4, 6), c(1)] <- NA
theDF[c(3, 4, 8), c(3)] <- NA

simple.impute.default(theDF$A)
simple.impute.default(theDF$A, mean)
simple.impute.default(theDF$A, constant(4))

Run the code above in your browser using DataLab