Running ‘testthat.R’ [3s/6s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(cutpointr)
  > 
  > test_check("cutpointr")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  cutpointr
   --- call from context --- 
  sanitize_metric(m, m_name = metric_name, n = nrow(roccurve))
   --- call from argument --- 
  if (dim(m)[2] == 1 & class(m) == "matrix") {
      res <- m
      if (is.null(colnames(res))) 
          colnames(res) <- m_name
  } else {
      stop(paste("The metric function should return a numeric vector", 
          "or a one-column matrix or data.frame."))
  }
   --- R stacktrace ---
  where 1: sanitize_metric(m, m_name = metric_name, n = nrow(roccurve))
  where 2: optimize_metric(data = data, x = x, class = class, metric_func = metric_func, 
      pos_class = pos_class, neg_class = neg_class, minmax = "max", 
      direction = direction, metric_name = metric_name, tol_metric = tol_metric, 
      use_midpoints = use_midpoints, ...)
  where 3: method(data = dat$data[[1]], x = predictor, class = outcome, 
      metric_func = metric, direction = direction, pos_class = pos_class, 
      neg_class = neg_class, tol_metric = tol_metric, use_midpoints = use_midpoints, 
      ...)
  where 4: cutpointr_internal(x, class, subgroup, method, metric, pos_class, 
      neg_class, direction, boot_runs, boot_stratify, use_midpoints, 
      break_ties, na.rm, allowParallel, predictor, outcome, mod_name, 
      subgroup_var, tol_metric, ...)
  where 5: cutpointr.default(suicide, dsi, suicide)
  where 6 at testthat/test-cutpointr.R#7: cutpointr(suicide, dsi, suicide)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 17: test_code(desc, code, env = parent.frame())
  where 18 at testthat/test-cutpointr.R#5: test_that("Cutpointr returns a cutpointr without NAs and a certain Nr of rows", 
      {
          data(suicide)
          opt_cut <- cutpointr(suicide, dsi, suicide)
          expect_true("cutpointr" %in% class(opt_cut))
          expect_that(nrow(opt_cut), equals(1))
          expect_that(sum(is.na(opt_cut)), equals(1))
          expect_silent(plot(opt_cut))
          expect_silent(print(plot_metric(opt_cut)))
          expect_silent(print(plot_roc(opt_cut)))
          expect_silent(print(plot_x(opt_cut)))
          expect_silent(print(plot_precision_recall(opt_cut)))
          expect_silent(print(plot_sensitivity_specificity(opt_cut)))
      })
  where 19: eval(code, test_env)
  where 20: eval(code, test_env)
  where 21: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 22: doTryCatch(return(expr), name, parentenv, handler)
  where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 27: tryCatchList(expr, classes, parentenv, handlers)
  where 28: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 29: test_code(NULL, exprs, env)
  where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 31: force(code)
  where 32: doWithOneRestart(return(expr), restart)
  where 33: withOneRestart(expr, restarts[[1L]])
  where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 35: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 36: FUN(X[[i]], ...)
  where 37: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 44: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 45: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 46: test_check("cutpointr")
  
   --- value of length: 2 type: logical ---
  [1]  TRUE FALSE
   --- function from context --- 
  function (m, m_name, n, silent = TRUE) 
  {
      if ("data.frame" %in% class(m)) {
          m <- as.matrix(m)
      }
      if (!is.null(dim(m))) {
          if (dim(m)[2] == 1 & class(m) == "matrix") {
              res <- m
              if (is.null(colnames(res))) 
                  colnames(res) <- m_name
          }
          else {
              stop(paste("The metric function should return a numeric vector", 
                  "or a one-column matrix or data.frame."))
          }
      }
      else if (is.numeric(m)) {
          res <- matrix(m, ncol = 1, dimnames = list(NULL, m_name))
      }
      else {
          stop(paste("Can't process metric of type", class(m)))
      }
      finite_res <- is.finite(res)
      if (any(!finite_res)) {
          if (!silent) 
              message("Converting non-finite metric values to NA")
          res[!finite_res] <- NA
      }
      if (nrow(res) != n) {
          stop("Number of returned metric values not equal to n")
      }
      colnames(res) <- make.names(colnames(res))
      return(res)
  }
  <bytecode: 0x55dcfa7844f0>
  <environment: namespace:cutpointr>
   --- function search by body ---
  Function sanitize_metric in namespace cutpointr has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1