impNA: Impute Missing Values

View source: R/statLearn.R

impNAR Documentation

Impute Missing Values

Description

Replace missing values in a vector using a function (by default the mean) on this vector.

Usage

impNA(x, fn = mean, ...)

Arguments

x

A numeric vector

fn

A function to apply to all values in the vector x

...

Additional arguments to be passed to function fn

Value

Vector x with all missing values replaced

Examples

v1=c(2,5,3,NA,2,4,1,NA)
#Replace values with the mean
impNA(v1,na.rm=TRUE)
#Replace values with the minimum
impNA(v1,min,na.rm=TRUE)

smallstuff documentation built on June 2, 2022, 5:06 p.m.