Description Usage Arguments Details Value Examples
When the mean/median/mode method is used: character vectors and factors are imputed with the mode.
1 |
data |
A data frame with factor or numeric variables. When columns are of type "character", method=="mode" . |
method |
Either "mean/median/mode". Only works if object = NULL, that is missing , NA |
Numeric and integer vectors are imputed with the mean/median.For imputing missing values the function is impute
.
An imputed dataframe data with method selected by user
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #Dummy dataset
dat <- data.frame(x=sample(letters[1:3],20,TRUE),
y=sample(letters[1:3],20,TRUE),
w=rnorm(20),
z=sample(letters[1:3],20,TRUE),
b = as.logical(sample(0:1,20,TRUE)),
stringsAsFactors=FALSE)
dat[c(5,10,15),1] <- NA
dat[c(3,7),2] <- NA
dat[c(1,3,5),3] <- NA
dat[c(4,5,9),4] <- NA
dat[c(4,5,9),5] <- NA
dat[,4] <- factor(dat[,4] )
#Usage
impute(dat,method = "mean")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.