Skip to content

Commit

Permalink
make regressionImp() works with data.table
Browse files Browse the repository at this point in the history
only tested with `family = "AUTO"`. closes #34
  • Loading branch information
GregorDeCillia committed Apr 16, 2020
1 parent 53ced60 commit e6ad8e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/regressionImp.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ regressionImp_work <- function(formula, family, robust, data, imp_var, imp_suffi
rhs <- formchar[3]
rhs2 <- gsub(" ", "", strsplit(rhs, "\\+")[[1]])
#Missings in RHS variables
TFna2 <- apply(data[, c(rhs2), drop = FALSE], 1, function(x) !any(is.na(x)))
TFna2 <- apply(subset(data, select = rhs2), 1, function(x) !any(is.na(x)))
for(lhsV in lhs) {
form <- as.formula(paste(lhsV, "~", rhs))
lhs_vector <- data[[lhsV]]
Expand All @@ -92,7 +92,7 @@ regressionImp_work <- function(formula, family, robust, data, imp_var, imp_suffi
} else {
if (!inherits(family, "function")) {
if (family == "AUTO") {
TFna <- TFna2 & !is.na(data[, lhsV])
TFna <- TFna2 & !is.na(lhs_vector)
if (inherits(lhs_vector, "numeric")) {
nLev <- 0
if (robust) {
Expand Down Expand Up @@ -162,7 +162,7 @@ regressionImp_work <- function(formula, family, robust, data, imp_var, imp_suffi
}
}
}else{
TFna1 <- is.na(data[, lhsV])
TFna1 <- is.na(lhs_vector)
TFna3 <- TFna1 & TFna2
tmp <- data[TFna3, ]
tmp[, lhsV] <- 1
Expand Down

0 comments on commit e6ad8e6

Please sign in to comment.