Skip to content

Commit

Permalink
Use cli erros in rsplit.R Fixes #512
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHWade committed Aug 15, 2024
1 parent 5eb77d4 commit 0542408
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/rsplit.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
rsplit <- function(data, in_id, out_id) {
if (!is.data.frame(data) & !is.matrix(data)) {
rlang::abort("`data` must be a data frame.")
cli::cli_abort("`data` must be a data frame.")
}

if (!is.integer(in_id) | any(in_id < 1)) {
rlang::abort("`in_id` must be a positive integer vector.")
cli::cli_abort("`in_id` must be a positive integer vector.")
}

if (!all(is.na(out_id))) {
if (!is.integer(out_id) | any(out_id < 1)) {
rlang::abort("`out_id` must be a positive integer vector.")
cli::cli_abort("`out_id` must be a positive integer vector.")
}
}

if (length(in_id) == 0) {
rlang::abort("At least one row should be selected for the analysis set.")
cli::cli_abort("At least one row should be selected for the analysis set.")
}

structure(
Expand Down Expand Up @@ -88,13 +88,13 @@ as.data.frame.rsplit <-
data = "analysis",
...) {
if (!is.null(row.names)) {
rlang::warn(paste0(
cli::cli_warn(paste0(
"`row.names` is kept for consistency with the underlying class but ",
"non-NULL values will be ignored."
))
}
if (optional) {
rlang::warn(paste0(
cli::cli_warn(paste0(
"`optional` is kept for consistency with the underlying class but ",
"TRUE values will be ignored."
))
Expand All @@ -107,7 +107,7 @@ as.data.frame.rsplit <-
"There is no assessment data set for an `rsplit` object",
" with class `", rsplit_class, "`."
)
rlang::abort(msg)
cli::cli_abort(msg)
}
ind <- as.integer(x, data = data, ...)
permuted_col <- vctrs::vec_slice(x$data, ind) %>%
Expand Down

0 comments on commit 0542408

Please sign in to comment.