Skip to content

Commit

Permalink
remove new argument from exported function
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Aug 28, 2024
1 parent 48721b7 commit 971be45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions R/convert_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ check_dup_names <- function(x, y, call = rlang::caller_env()) {
#' @param x A data frame, matrix, or sparse matrix.
#' @return A data frame, matrix, or sparse matrix.
#' @export
maybe_matrix <- function(x, call = rlang::caller_env()) {
maybe_matrix <- function(x) {
inher(x, c("data.frame", "matrix", "dgCMatrix"), cl = match.call())
if (is.data.frame(x)) {
non_num_cols <- vapply(x, function(x) !is.numeric(x), logical(1))
Expand All @@ -376,8 +376,7 @@ maybe_matrix <- function(x, call = rlang::caller_env()) {

cli::cli_abort(
"The column{?s} {.val {non_num_cols}} {?is/are} non-numeric, so the
data cannot be converted to a numeric matrix.",
call = call
data cannot be converted to a numeric matrix."
)
}
x <- as.matrix(x)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/convert_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
Code
parsnip::maybe_matrix(ames[, c("Year_Built", "Neighborhood")])
Condition
Error:
Error in `parsnip::maybe_matrix()`:
! The column "Neighborhood" is non-numeric, so the data cannot be converted to a numeric matrix.

---

Code
parsnip::maybe_matrix(Chicago[, c("ridership", "date")])
Condition
Error:
Error in `parsnip::maybe_matrix()`:
! The column "date" is non-numeric, so the data cannot be converted to a numeric matrix.

0 comments on commit 971be45

Please sign in to comment.