Skip to content

Commit

Permalink
remove missing values in test()
Browse files Browse the repository at this point in the history
  • Loading branch information
qddyy committed Nov 27, 2024
1 parent 9def687 commit d2ac38a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions R/PermuTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ PermuTest <- R6Class(
)

get_data <- function(call, env) {
data_exprs <- as.list(call)[-1]
data_exprs <- as.list.default(call)[-1]

n_data <- length(data_exprs)

if (n_data == 1 && is.list(data_1 <- eval(data_exprs[[1]], envir = env))) {
Expand All @@ -465,11 +466,19 @@ get_data <- function(call, env) {
}

data_i <- eval(data_exprs[[i]], envir = env)

if (!is.numeric(data_i)) {
stop("Sample ", i, " is not numeric")
} else if (anyNA(data_i)) {
stop("Sample ", i, " contains NA")
} else data_i
}
if (anyNA(data_i)) {
warning("Sample ", i, " contains missing values, removed")
data_i <- data_i[!is.na(data_i)]
}
if (length(data_i) < 1) {
stop("Sample ", i, " does not contain enough observations")
}

data_i
}
), data_names)
}

0 comments on commit d2ac38a

Please sign in to comment.