na.roughfix: Rough Imputation of Missing Values

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/na.roughfix.R

Description

Impute Missing Values by median/mode.

Usage

1
na.roughfix(object, ...)

Arguments

object

a data frame or numeric matrix.

...

further arguments special methods could require.

Value

A completed data matrix or data frame. For numeric variables, NAs are replaced with column medians. For factor variables, NAs are replaced with the most frequent levels (breaking ties at random). If object contains no NAs, it is returned unaltered.

Note

This is used as a starting point for imputing missing values by random forest.

Author(s)

Andy Liaw

See Also

rfImpute, randomForest.

Examples

1
2
3
4
5
6
7
8
data(iris)
iris.na <- iris
set.seed(111)
## artificially drop some data values.
for (i in 1:4) iris.na[sample(150, sample(20)), i] <- NA
iris.roughfix <- na.roughfix(iris.na)
iris.narf <- randomForest(Species ~ ., iris.na, na.action=na.roughfix)
print(iris.narf)

extendedForest documentation built on May 31, 2017, 1:58 a.m.

Search within the extendedForest package
Search all R packages, documentation and source code