Skip to content

Commit

Permalink
edits to handle NAs in species column properly
Browse files Browse the repository at this point in the history
  • Loading branch information
EricArcher committed Mar 14, 2023
1 parent e504651 commit fa97b2d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ predict.banter_model <- function(object, new.data, ...) {
}
}

df <- stats::na.omit(df)
is.missing <- sapply(
setdiff(colnames(df), "species"),
function(col) is.na(df[, col])
)
df <- df[!apply(is.missing, 1, any), ]

result <- list(
events = df,
Expand All @@ -213,8 +217,8 @@ predict.banter_model <- function(object, new.data, ...) {
if("species" %in% colnames(df)) {
result$predict.df <- dplyr::mutate(
result$predict.df,
original = make.names(df$species, allow_ = FALSE),
correct = .data$original == .data$predicted
original = ifelse(is.na(df$species), NA, make.names(df$species, allow_ = FALSE)),
correct = ifelse(is.na(df$species), NA, .data$original == .data$predicted)
)
conf.df <- result$predict.df
conf.df$predicted <- factor(
Expand Down

0 comments on commit fa97b2d

Please sign in to comment.