Description Usage Arguments Author(s) References Examples
Handles missing values by filling in with mean, and adding a dummy variable.
1 2 3 | na.dummy(object, ...)
fix_predvars(object)
|
object |
an R object, typically a data.frame |
... |
other arguments (not used) |
1 2 3 4 5 6 7 8 9 | df <- structure(list(Y = c(3.83, 22.73, 13.85, 14.09, 20.55, 18.51,
17.76, 9.42, 15.88, 27.81), X1 = 1:10, X2 = c(2L, NA, NA, 4L,
8L, 7L, 6L, 1L, 3L, 9L)), .Names = c("Y", "X1", "X2"), row.names = c(NA,
-10L), class = "data.frame")
(m <- lm(Y~X1+X2, df, na.action = na.dummy))
m2 <- fix_predvars(m)
attr(terms(m2), "predvars")
predict(m2, newdata = data.frame(X1=2,X2=NA_real_))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.