Description Usage Arguments Details See Also Examples
Replace missing values using multivariate statistical model
1 2 3 4 5 6 7 8 9 10 11 12 13 |
data |
a data.frame. |
formula |
an object of class " |
learnFun |
learning function in form |
predictFun |
function used for making predictions in form
|
... |
further arguments passed to |
family |
in |
Multiple convenience wrappers allow user to use: linear regression (na_lm
),
generalized linear models (na_glm
), recursive partitioning and regression
trees (na_rpart
), random forests (na_rf
) and additionally, for
categorical data: naive Bayes (na_nb
) and k-nearest neighbour classifiers
(na_knn
). Both na_rpart
and na_rf
can be used for predicting
continuous and categorical variables.
lm
, glm
, rpart
,
randomForest
, naiveBayes
,
knn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | set.seed(123)
dat <- mtcars
dat$disp[sample.int(nrow(dat), 10)] <- NA
dat$gear[sample.int(nrow(dat), 10)] <- NA
dat$gear <- as.factor(dat$gear)
na_predict(dat, disp ~ mpg + drat, learnFun = glm, predictFun = function(object, newdata) {
predict(object, newdata= newdata, type = "response") })
na_predict(dat, gear ~ mpg + drat, learnFun = e1071::naiveBayes)
# continuous variables
na_lm(dat, disp ~ mpg + drat)
na_glm(dat, disp ~ mpg + drat)
na_rpart(dat, disp ~ mpg + drat)
na_rf(dat, disp ~ mpg + drat)
# categorical variables
na_nb(dat, gear ~ mpg + drat)
na_knn(dat, gear ~ mpg + drat)
na_rpart(dat, factor(gear) ~ mpg + drat)
na_rf(dat, factor(gear) ~ mpg + drat)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.