File: na.roughfix.Rd

package info (click to toggle)
r-cran-randomforest 4.7-1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 496 kB
  • sloc: ansic: 1,897; fortran: 366; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
\name{na.roughfix}
\alias{na.roughfix}
\alias{na.roughfix.default}
\alias{na.roughfix.data.frame}
\title{Rough Imputation of Missing Values}
\description{
  Impute Missing Values by median/mode.
}
\usage{
na.roughfix(object, ...)
}
\arguments{
  \item{object}{a data frame or numeric matrix.}
  \item{\dots}{further arguments special methods could require.}
}
\value{
  A completed data matrix or data frame.  For numeric variables,
  \code{NA}s are replaced with column medians.  For factor variables,
  \code{NA}s are replaced with the most frequent levels (breaking ties
  at random).  If \code{object} contains no \code{NA}s, it is returned
  unaltered. 
}
\note{
  This is used as a starting point for imputing missing values by random
  forest.
}
%\references{
%}
\seealso{
\code{\link{rfImpute}}, \code{\link{randomForest}}.
}
\examples{
data(iris)
iris.na <- iris
set.seed(111)
## artificially drop some data values.
for (i in 1:4) iris.na[sample(150, sample(20, 1)), i] <- NA
iris.roughfix <- na.roughfix(iris.na)
iris.narf <- randomForest(Species ~ ., iris.na, na.action=na.roughfix)
print(iris.narf)
}
\author{Andy Liaw}
\keyword{NA}