na.roughfix

0th

Percentile

Rough Imputation of Missing Values

Impute Missing Values by median/mode.

Keywords
NA
Usage
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.

See Also

rfImpute, randomForest.

Aliases
  • na.roughfix
  • na.roughfix.default
  • na.roughfix.data.frame
Examples
# NOT RUN {
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)
# }
Documentation reproduced from package randomForest, version 4.6-14, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.