Skip to content

Commit

Permalink
Add function for coercing uids to numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
stitam committed Dec 22, 2024
1 parent 48011c6 commit 8519771
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,16 @@ get_mc_cores <- function(mc_cores, verbose = getOption("verbose")) {
mc_cores <- n_cores
}
return(mc_cores)
}

#' Convert a vector to numeric
#'
#' @param x vector; Vector to convert.
#' @noRd
as_numeric <- function(x) {
numeric_x <- suppressWarnings(as.numeric(x))
if (any(is.na(numeric_x) & !is.na(x))) {
stop("Query must be either an ncbi_uid object or a vector of UIDs.")
}
return(numeric_x)
}

0 comments on commit 8519771

Please sign in to comment.