Running 'testthat.R' [47s/42s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library(testthat)
  > library(multistateutils)
  > 
  > test_check("multistateutils")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(trans_mat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(trans_mat)
  where 2: state_occupancy(models, trans_mat, newdata, tcovs, start_time, 
      start_state, ci, M, agelimit, agecol, agescale)
  where 3 at testthat/test_cohort.R#63: cohort_simulation(models, cbind(ebmt3, agecont = runif(nrow(ebmt3), 
      20, 85)), tmat, agelimit = 36525, agescale = 365.25, agecol = "agecont")
  where 4: eval(code, test_env)
  where 5: eval(code, test_env)
  where 6: 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 7: doTryCatch(return(expr), name, parentenv, handler)
  where 8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 9: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 12: tryCatchList(expr, classes, parentenv, handlers)
  where 13: 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 14: test_code(desc, code, env = parent.frame())
  where 15 at testthat/test_cohort.R#56: test_that("cohort_simulation age limit works", {
      tmat <- trans.illdeath()
      models <- readRDS(models_fn)
      sim <- cohort_simulation(models, ebmt3, tmat)
      expect_equal(max(sim$time) > 36525, TRUE)
      sim_wagelimit <- cohort_simulation(models, cbind(ebmt3, agecont = runif(nrow(ebmt3), 
          20, 85)), tmat, agelimit = 36525, agescale = 365.25, 
          agecol = "agecont")
      expect_equal(max(sim_wagelimit$time) <= 36525, TRUE)
  })
  where 16: eval(code, test_env)
  where 17: eval(code, test_env)
  where 18: 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 19: doTryCatch(return(expr), name, parentenv, handler)
  where 20: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 21: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 22: doTryCatch(return(expr), name, parentenv, handler)
  where 23: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 24: tryCatchList(expr, classes, parentenv, handlers)
  where 25: 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 26: test_code(NULL, exprs, env)
  where 27: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 28: force(code)
  where 29: doWithOneRestart(return(expr), restart)
  where 30: withOneRestart(expr, restarts[[1L]])
  where 31: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 32: 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 33: FUN(X[[i]], ...)
  where 34: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 35: force(code)
  where 36: doWithOneRestart(return(expr), restart)
  where 37: withOneRestart(expr, restarts[[1L]])
  where 38: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 39: 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 40: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 41: 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 42: 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 43: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 1. Error: cohort_simulation age limit works (@test_cohort.R#63)  ------------
  the condition has length > 1
  Backtrace:
   1. multistateutils::cohort_simulation(...)
   2. multistateutils:::state_occupancy(...)
   3. multistateutils:::get_sink_states(trans_mat)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(trans_mat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(trans_mat)
  where 2: state_occupancy(models, trans_mat, newdata_ext, tcovs, initial_times, 
      start_states, ci, M, agelimit, agecol, agescale)
  where 3 at testthat/test_lengthofstay.R#96: length_of_stay(models, cbind(newdata, agecont = 39), tmat, 365, 
      start_state = 1, agelimit = 36525, agecol = "agecont", agescale = 365.25, 
      N = nsims)
  where 4: eval(code, test_env)
  where 5: eval(code, test_env)
  where 6: 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 7: doTryCatch(return(expr), name, parentenv, handler)
  where 8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 9: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 12: tryCatchList(expr, classes, parentenv, handlers)
  where 13: 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 14: test_code(desc, code, env = parent.frame())
  where 15 at testthat/test_lengthofstay.R#88: test_that("length_of_stay age limit works", {
      models <- readRDS(models_fn)
      newdata <- data.frame(age = "20-40", dissub = "AML")
      tmat <- trans.illdeath()
      nsims <- 1000
      los1 <- length_of_stay(models, newdata, tmat, 36525, start_state = 1, 
          N = nsims)
      los2 <- length_of_stay(models, cbind(newdata, agecont = 39), 
          tmat, 365, start_state = 1, agelimit = 36525, agecol = "agecont", 
          agescale = 365.25, N = nsims)
      los3 <- length_of_stay(models, cbind(newdata, agecont = 39), 
          tmat, 36525, start_state = 1, agelimit = 36525, agecol = "agecont", 
          agescale = 365.25, N = nsims)
      expect_equal("oldage" %in% colnames(los1), FALSE)
      expect_equal(los2$oldage, 0)
      expect_equal("oldage" %in% colnames(los3) && los3$oldage > 
          0, TRUE)
  })
  where 16: eval(code, test_env)
  where 17: eval(code, test_env)
  where 18: 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 19: doTryCatch(return(expr), name, parentenv, handler)
  where 20: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 21: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 22: doTryCatch(return(expr), name, parentenv, handler)
  where 23: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 24: tryCatchList(expr, classes, parentenv, handlers)
  where 25: 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 26: test_code(NULL, exprs, env)
  where 27: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 28: force(code)
  where 29: doWithOneRestart(return(expr), restart)
  where 30: withOneRestart(expr, restarts[[1L]])
  where 31: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 32: 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 33: FUN(X[[i]], ...)
  where 34: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 35: force(code)
  where 36: doWithOneRestart(return(expr), restart)
  where 37: withOneRestart(expr, restarts[[1L]])
  where 38: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 39: 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 40: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 41: 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 42: 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 43: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 2. Error: length_of_stay age limit works (@test_lengthofstay.R#96)  ---------
  the condition has length > 1
  Backtrace:
   1. multistateutils::length_of_stay(...)
   2. multistateutils:::state_occupancy(...)
   3. multistateutils:::get_sink_states(trans_mat)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(tmat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(tmat)
  where 2 at testthat/test_msprep2.R#65: msprep2(entry, tmat, censors = censor_time, covars = covars)
  where 3: eval(code, test_env)
  where 4: eval(code, test_env)
  where 5: 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 6: doTryCatch(return(expr), name, parentenv, handler)
  where 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 8: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 11: tryCatchList(expr, classes, parentenv, handlers)
  where 12: 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 13: test_code(desc, code, env = parent.frame())
  where 14 at testthat/test_msprep2.R#58: test_that("msprep2 produces same output on ebmt3 as msprep", 
      {
          entry <- readRDS(entry_fn)
          censor_time <- readRDS(censors_fn)
          covars <- readRDS(covars_fn)
          long <- readRDS(long_fn)
          tmat <- mstate::trans.illdeath(c("transplant", "pr", 
              "rfs"))
          full <- msprep2(entry, tmat, censors = censor_time, covars = covars)
          expect_equal(dim(full), dim(long))
          expect_equal(all(sapply(colnames(full), function(x) {
              all(full[[x]] == long[[x]])
          })), TRUE)
      })
  where 15: eval(code, test_env)
  where 16: eval(code, test_env)
  where 17: 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 18: doTryCatch(return(expr), name, parentenv, handler)
  where 19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 20: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 23: tryCatchList(expr, classes, parentenv, handlers)
  where 24: 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 25: test_code(NULL, exprs, env)
  where 26: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 27: force(code)
  where 28: doWithOneRestart(return(expr), restart)
  where 29: withOneRestart(expr, restarts[[1L]])
  where 30: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 31: 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 32: FUN(X[[i]], ...)
  where 33: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: 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 39: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 40: 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 41: 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 42: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 3. Error: msprep2 produces same output on ebmt3 as msprep (@test_msprep2.R#65
  the condition has length > 1
  Backtrace:
   1. multistateutils::msprep2(...)
   2. multistateutils:::get_sink_states(tmat)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(tmat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(tmat)
  where 2 at testthat/test_msprep2.R#94: msprep2(entry2, tmat, censors = censor2, covars = covars2, idcol = "patid")
  where 3: eval(code, test_env)
  where 4: eval(code, test_env)
  where 5: 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 6: doTryCatch(return(expr), name, parentenv, handler)
  where 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 8: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 11: tryCatchList(expr, classes, parentenv, handlers)
  where 12: 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 13: test_code(desc, code, env = parent.frame())
  where 14 at testthat/test_msprep2.R#75: test_that("msprep2 idcolumn works", {
      entry <- readRDS(entry_fn)
      censor_time <- readRDS(censors_fn)
      covars <- readRDS(covars_fn)
      long <- readRDS(long_fn)
      tmat <- mstate::trans.illdeath(c("transplant", "pr", "rfs"))
      entry2 <- entry
      censor2 <- censor_time
      covars2 <- covars
      entry2$patid <- entry$id
      censor2$patid <- censor2$id
      covars2$patid <- covars2$id
      entry2 <- entry2[, setdiff(colnames(entry2), "id")]
      censor2 <- censor2[, setdiff(colnames(censor2), "id")]
      covars2 <- covars2[, setdiff(colnames(covars2), "id")]
      full <- msprep2(entry2, tmat, censors = censor2, covars = covars2, 
          idcol = "patid")
      expect_equal(dim(full), dim(long))
      expect_equal(all(sapply(colnames(full), function(x) {
          all(full[[x]] == long[[x]])
      })), TRUE)
  })
  where 15: eval(code, test_env)
  where 16: eval(code, test_env)
  where 17: 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 18: doTryCatch(return(expr), name, parentenv, handler)
  where 19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 20: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 23: tryCatchList(expr, classes, parentenv, handlers)
  where 24: 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 25: test_code(NULL, exprs, env)
  where 26: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 27: force(code)
  where 28: doWithOneRestart(return(expr), restart)
  where 29: withOneRestart(expr, restarts[[1L]])
  where 30: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 31: 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 32: FUN(X[[i]], ...)
  where 33: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: 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 39: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 40: 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 41: 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 42: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 4. Error: msprep2 idcolumn works (@test_msprep2.R#94)  ----------------------
  the condition has length > 1
  Backtrace:
   1. multistateutils::msprep2(...)
   2. multistateutils:::get_sink_states(tmat)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(tmat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(tmat)
  where 2 at testthat/test_msprep2.R#156: msprep2(entry, tmat, censors = censor_time, covars = data.frame(id = 1:10, 
      age = 50:59))
  where 3: eval(code, test_env)
  where 4: eval(code, test_env)
  where 5: 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 6: doTryCatch(return(expr), name, parentenv, handler)
  where 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 8: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 11: tryCatchList(expr, classes, parentenv, handlers)
  where 12: 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 13: test_code(desc, code, env = parent.frame())
  where 14 at testthat/test_msprep2.R#140: test_that("msprep2 covars guards work", {
      entry <- readRDS(entry_fn)
      censor_time <- readRDS(censors_fn)
      covars <- readRDS(covars_fn)
      long <- readRDS(long_fn)
      tmat <- mstate::trans.illdeath(c("transplant", "pr", "rfs"))
      expect_error(msprep2(entry, tmat, censors = censor_time, 
          covars = data.frame(age = 50:59)), "Error: id field 'id' not found in covars.")
      expect_error(msprep2(entry, tmat, censors = censor_time, 
          covars = data.frame(patid = 1:10, age = 50:59)), "Error: id field 'id' not found in covars.")
      full <- msprep2(entry, tmat, censors = censor_time, covars = data.frame(id = 1:10, 
          age = 50:59))
      expect_equal(ncol(full), 9)
      expect_equal(nrow(full) >= nrow(ebmt3), TRUE)
      output_age <- full$age[full$id %in% seq(10)]
      output_noage <- full$age[!full$id %in% seq(10)]
      expect_equal(all(!is.na(output_age)), TRUE)
      expect_equal(all(is.na(output_noage)), TRUE)
  })
  where 15: eval(code, test_env)
  where 16: eval(code, test_env)
  where 17: 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 18: doTryCatch(return(expr), name, parentenv, handler)
  where 19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 20: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 23: tryCatchList(expr, classes, parentenv, handlers)
  where 24: 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 25: test_code(NULL, exprs, env)
  where 26: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 27: force(code)
  where 28: doWithOneRestart(return(expr), restart)
  where 29: withOneRestart(expr, restarts[[1L]])
  where 30: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 31: 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 32: FUN(X[[i]], ...)
  where 33: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: 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 39: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 40: 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 41: 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 42: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 5. Error: msprep2 covars guards work (@test_msprep2.R#156)  -----------------
  the condition has length > 1
  Backtrace:
   1. multistateutils::msprep2(...)
   2. multistateutils:::get_sink_states(tmat)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(tmat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(tmat)
  where 2 at testthat/test_msprep2.R#178: msprep2(entry, tmat, censors = censor_time, covars = covars, 
      start_times = start_missing)
  where 3: eval(code, test_env)
  where 4: eval(code, test_env)
  where 5: 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 6: doTryCatch(return(expr), name, parentenv, handler)
  where 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 8: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 11: tryCatchList(expr, classes, parentenv, handlers)
  where 12: 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 13: test_code(desc, code, env = parent.frame())
  where 14 at testthat/test_msprep2.R#168: test_that("msprep2 start_time guards work", {
      entry <- readRDS(entry_fn)
      censor_time <- readRDS(censors_fn)
      covars <- readRDS(covars_fn)
      long <- readRDS(long_fn)
      tmat <- mstate::trans.illdeath(c("transplant", "pr", "rfs"))
      start_missing <- data.frame(id = 1:10, start_time = 1)
      full <- msprep2(entry, tmat, censors = censor_time, covars = covars, 
          start_times = start_missing)
      expect_equal(ncol(full), 10)
      expect_equal(nrow(full) >= nrow(ebmt3), TRUE)
      start_times <- full$Tstart[full$id %in% seq(10) & full$from == 
          1]
      default_start_times <- full$Tstart[!full$id %in% seq(10) & 
          full$from == 1]
      expect_equal(all(start_times == 1), TRUE)
      expect_equal(all(default_start_times == 0), TRUE)
      expect_error(msprep2(entry, tmat, censors = censor_time, 
          covars = covars, start_times = data.frame(patid = 1:10, 
              start_time = 2)), "Error: id field 'id' not found in start_times.")
      expect_error(msprep2(entry, tmat, censors = censor_time, 
          covars = covars, start_times = data.frame(id = 1:10, 
              time = 2)), "Error: column start_time not found in start_times.")
  })
  where 15: eval(code, test_env)
  where 16: eval(code, test_env)
  where 17: 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 18: doTryCatch(return(expr), name, parentenv, handler)
  where 19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 20: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 23: tryCatchList(expr, classes, parentenv, handlers)
  where 24: 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 25: test_code(NULL, exprs, env)
  where 26: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 27: force(code)
  where 28: doWithOneRestart(return(expr), restart)
  where 29: withOneRestart(expr, restarts[[1L]])
  where 30: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 31: 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 32: FUN(X[[i]], ...)
  where 33: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: 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 39: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 40: 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 41: 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 42: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 6. Error: msprep2 start_time guards work (@test_msprep2.R#178)  -------------
  the condition has length > 1
  Backtrace:
   1. multistateutils::msprep2(...)
   2. multistateutils:::get_sink_states(tmat)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(tmat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(tmat)
  where 2 at testthat/test_msprep2.R#216: msprep2(entry, tmat, censors = censor_time, covars = covars, 
      start_states = start_missing)
  where 3: eval(code, test_env)
  where 4: eval(code, test_env)
  where 5: 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 6: doTryCatch(return(expr), name, parentenv, handler)
  where 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 8: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 11: tryCatchList(expr, classes, parentenv, handlers)
  where 12: 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 13: test_code(desc, code, env = parent.frame())
  where 14 at testthat/test_msprep2.R#198: test_that("msprep2 start_states guards work", {
      entry <- readRDS(entry_fn)
      censor_time <- readRDS(censors_fn)
      covars <- readRDS(covars_fn)
      long <- readRDS(long_fn)
      tmat <- mstate::trans.illdeath(c("transplant", "pr", "rfs"))
      expect_error(msprep2(entry, tmat, censors = censor_time, 
          covars = covars, start_states = data.frame(patid = 1:10, 
              start_state = 1)), "Error: id field 'id' not found in start_states.")
      expect_error(msprep2(entry, tmat, censors = censor_time, 
          covars = covars, start_states = data.frame(id = 1:10, 
              state = 1)), "Error: column start_state not found in start_states.")
      start_missing <- data.frame(id = 1:10, start_state = 2)
      full <- msprep2(entry, tmat, censors = censor_time, covars = covars, 
          start_states = start_missing)
      expect_equal(ncol(full), 10)
      expect_equal(nrow(full) >= nrow(ebmt3), TRUE)
      start_states <- full$from[full$id %in% seq(10) & full$Tstart == 
          0]
      default_start_states <- full$from[!full$id %in% seq(10) & 
          full$Tstart == 0]
      expect_equal(all(start_states == 2), TRUE)
      expect_equal(all(default_start_states == 1), TRUE)
      start_states <- data.frame(id = 1:10, start_state = seq(10))
      expect_error(msprep2(entry, tmat, censors = censor_time, 
          covars = covars, start_states = start_states), "Error: start_state column must be state name or number.")
      start_states <- data.frame(id = 1:9, start_state = rep(c("transplant", 
          "pr", "rfs"), 3))
      full <- msprep2(entry, tmat, censors = censor_time, covars = covars, 
          start_states = start_states)
      expect_equal(ncol(full), 10)
      expect_equal(nrow(full) >= nrow(ebmt3), TRUE)
      start_states <- data.frame(id = 1:9, start_state = rep(c("heal", 
          "illness", "death"), 3))
      expect_error(msprep2(entry, tmat, censors = censor_time, 
          covars = covars, start_states = start_states), "Error: start_state column must be state name or number.")
  })
  where 15: eval(code, test_env)
  where 16: eval(code, test_env)
  where 17: 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 18: doTryCatch(return(expr), name, parentenv, handler)
  where 19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 20: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 23: tryCatchList(expr, classes, parentenv, handlers)
  where 24: 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 25: test_code(NULL, exprs, env)
  where 26: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 27: force(code)
  where 28: doWithOneRestart(return(expr), restart)
  where 29: withOneRestart(expr, restarts[[1L]])
  where 30: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 31: 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 32: FUN(X[[i]], ...)
  where 33: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: 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 39: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 40: 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 41: 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 42: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 7. Error: msprep2 start_states guards work (@test_msprep2.R#216)  -----------
  the condition has length > 1
  Backtrace:
   1. multistateutils::msprep2(...)
   2. multistateutils:::get_sink_states(tmat)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(tmat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(tmat)
  where 2 at testthat/test_msprep2.R#271: msprep2(df, tmat)
  where 3: eval(code, test_env)
  where 4: eval(code, test_env)
  where 5: 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 6: doTryCatch(return(expr), name, parentenv, handler)
  where 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 8: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 11: tryCatchList(expr, classes, parentenv, handlers)
  where 12: 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 13: test_code(desc, code, env = parent.frame())
  where 14 at testthat/test_msprep2.R#244: test_that("msprep2 works with repeated state entries", {
      entry <- readRDS(entry_fn)
      censor_time <- readRDS(censors_fn)
      covars <- readRDS(covars_fn)
      long <- readRDS(long_fn)
      tmat <- mstate::trans.illdeath(c("transplant", "pr", "rfs"))
      df <- data.frame(id = c(rep(1, 4), rep(2, 2), rep(3, 1), 
          rep(4, 3)), state = c("B", "A", "B", "C", "B", "C", "C", 
          "B", "A", "B"), time = c(6, 11, 16, 21, 7, 12, 8, 9, 
          14, 19))
      tmat <- matrix(c(NA, 3, NA, 1, NA, NA, 2, 4, NA), nrow = 3, 
          ncol = 3, dimnames = list(LETTERS[1:3], LETTERS[1:3]))
      out <- msprep2(df, tmat)
      exp_out <- data.frame(do.call("rbind", list(data.frame(id = 1, 
          from = 1, to = 2, trans = 1, Tstart = 0, Tstop = 6, time = 6, 
          status = 1), data.frame(id = 1, from = 1, to = 3, trans = 2, 
          Tstart = 0, Tstop = 6, time = 6, status = 0), data.frame(id = 1, 
          from = 2, to = 1, trans = 3, Tstart = 6, Tstop = 11, 
          time = 5, status = 1), data.frame(id = 1, from = 2, to = 3, 
          trans = 4, Tstart = 6, Tstop = 11, time = 5, status = 0), 
          data.frame(id = 1, from = 1, to = 2, trans = 1, Tstart = 11, 
              Tstop = 16, time = 5, status = 1), data.frame(id = 1, 
              from = 1, to = 3, trans = 2, Tstart = 11, Tstop = 16, 
              time = 5, status = 0), data.frame(id = 1, from = 2, 
              to = 1, trans = 3, Tstart = 16, Tstop = 21, time = 5, 
              status = 0), data.frame(id = 1, from = 2, to = 3, 
              trans = 4, Tstart = 16, Tstop = 21, time = 5, status = 1), 
          data.frame(id = 2, from = 1, to = 2, trans = 1, Tstart = 0, 
              Tstop = 7, time = 7, status = 1), data.frame(id = 2, 
              from = 1, to = 3, trans = 2, Tstart = 0, Tstop = 7, 
              time = 7, status = 0), data.frame(id = 2, from = 2, 
              to = 1, trans = 3, Tstart = 7, Tstop = 12, time = 5, 
              status = 0), data.frame(id = 2, from = 2, to = 3, 
              trans = 4, Tstart = 7, Tstop = 12, time = 5, status = 1), 
          data.frame(id = 3, from = 1, to = 2, trans = 1, Tstart = 0, 
              Tstop = 8, time = 8, status = 0), data.frame(id = 3, 
              from = 1, to = 3, trans = 2, Tstart = 0, Tstop = 8, 
              time = 8, status = 1), data.frame(id = 4, from = 1, 
              to = 2, trans = 1, Tstart = 0, Tstop = 9, time = 9, 
              status = 1), data.frame(id = 4, from = 1, to = 3, 
              trans = 2, Tstart = 0, Tstop = 9, time = 9, status = 0), 
          data.frame(id = 4, from = 2, to = 1, trans = 3, Tstart = 9, 
              Tstop = 14, time = 5, status = 1), data.frame(id = 4, 
              from = 2, to = 3, trans = 4, Tstart = 9, Tstop = 14, 
              time = 5, status = 0), data.frame(id = 4, from = 1, 
              to = 2, trans = 1, Tstart = 14, Tstop = 19, time = 5, 
              status = 1), data.frame(id = 4, from = 1, to = 3, 
              trans = 2, Tstart = 14, Tstop = 19, time = 5, status = 0))))
      expect_equal(dim(out), dim(exp_out))
      ncols <- ncol(out)
      column_check <- sapply(seq(ncols), function(i) all(out[, 
          i] == exp_out[, i]))
      expect_equal(all(column_check), TRUE)
  })
  where 15: eval(code, test_env)
  where 16: eval(code, test_env)
  where 17: 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 18: doTryCatch(return(expr), name, parentenv, handler)
  where 19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 20: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 23: tryCatchList(expr, classes, parentenv, handlers)
  where 24: 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 25: test_code(NULL, exprs, env)
  where 26: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 27: force(code)
  where 28: doWithOneRestart(return(expr), restart)
  where 29: withOneRestart(expr, restarts[[1L]])
  where 30: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 31: 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 32: FUN(X[[i]], ...)
  where 33: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: 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 39: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 40: 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 41: 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 42: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 8. Error: msprep2 works with repeated state entries (@test_msprep2.R#271)  --
  the condition has length > 1
  Backtrace:
   1. multistateutils::msprep2(df, tmat)
   2. multistateutils:::get_sink_states(tmat)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(trans_mat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(trans_mat)
  where 2: state_occupancy(models, trans_mat, newdata_ext, tcovs, initial_times, 
      start_states, ci, M, agelimit, agecol, agescale)
  where 3 at testthat/test_transitionprobs.R#153: predict_transitions(models, cbind(newdata, agecont = 39), tmat, 
      times = 36525, agelimit = 36525, agecol = "agecont", agescale = 365.25, 
      N = nsims)
  where 4: eval(code, test_env)
  where 5: eval(code, test_env)
  where 6: 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 7: doTryCatch(return(expr), name, parentenv, handler)
  where 8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 9: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 12: tryCatchList(expr, classes, parentenv, handlers)
  where 13: 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 14: test_code(desc, code, env = parent.frame())
  where 15 at testthat/test_transitionprobs.R#142: test_that("predict_transitions age limit works", {
      tmat <- trans.illdeath()
      newdata <- data.frame(age = "20-40", dissub = "AML")
      models <- readRDS(models_fn)
      nsims <- 1000
      rdes <- predict_transitions(models, newdata, tmat, times = 36525, 
          N = nsims)
      expect_equal(all(rdes[1:2, 8] < 1), TRUE)
      with_agelimit <- predict_transitions(models, cbind(newdata, 
          agecont = 39), tmat, times = 36525, agelimit = 36525, 
          agecol = "agecont", agescale = 365.25, N = nsims)
      expect_equal(all(with_agelimit[1, 7:8] == 0), TRUE)
      expect_equal(with_agelimit[2, 8] == 0, TRUE)
  })
  where 16: eval(code, test_env)
  where 17: eval(code, test_env)
  where 18: 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 19: doTryCatch(return(expr), name, parentenv, handler)
  where 20: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 21: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 22: doTryCatch(return(expr), name, parentenv, handler)
  where 23: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 24: tryCatchList(expr, classes, parentenv, handlers)
  where 25: 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 26: test_code(NULL, exprs, env)
  where 27: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 28: force(code)
  where 29: doWithOneRestart(return(expr), restart)
  where 30: withOneRestart(expr, restarts[[1L]])
  where 31: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 32: 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 33: FUN(X[[i]], ...)
  where 34: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 35: force(code)
  where 36: doWithOneRestart(return(expr), restart)
  where 37: withOneRestart(expr, restarts[[1L]])
  where 38: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 39: 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 40: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 41: 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 42: 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 43: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 9. Error: predict_transitions age limit works (@test_transitionprobs.R#153)  
  the condition has length > 1
  Backtrace:
   1. multistateutils::predict_transitions(...)
   2. multistateutils:::state_occupancy(...)
   3. multistateutils:::get_sink_states(trans_mat)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  multistateutils
   --- call from context --- 
  get_sink_states(tmat)
   --- call from argument --- 
  if (class(tmat) != "matrix") stop("Error: must provide a square transition matrix.")
   --- R stacktrace ---
  where 1: get_sink_states(tmat)
  where 2: eval_bare(expr, quo_get_env(quo))
  where 3: quasi_label(enquo(object), label, arg = "object")
  where 4 at testthat/test_utils.R#56: expect_equal(get_sink_states(tmat), "death")
  where 5: eval(code, test_env)
  where 6: eval(code, test_env)
  where 7: 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 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 10: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 11: doTryCatch(return(expr), name, parentenv, handler)
  where 12: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 13: tryCatchList(expr, classes, parentenv, handlers)
  where 14: 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 15: test_code(desc, code, env = parent.frame())
  where 16 at testthat/test_utils.R#53: test_that("get_sink_states correctly returns sink states", {
      tmat <- trans.illdeath()
      expect_equal(get_sink_states(tmat), "death")
      expect_error(get_sink_states(NULL), "Error: must provide a square transition matrix.")
      df_tmat <- data.frame(healthy = NA, illness = c(1, NA, NA), 
          death = c(2, 3, NA))
      row.names(df_tmat) <- c("healthy", "illness", "death")
      expect_error(get_sink_states(df_tmat), "Error: must provide a square transition matrix.")
      mat_nonsquare <- matrix(c(NA, NA, NA, NA, 1, NA, NA, NA, 
          2, 3, NA, NA), ncol = 3, nrow = 4)
      expect_error(get_sink_states(mat_nonsquare), "Error: must provide a square transition matrix.")
      mat_nonsquare <- matrix(c(NA, 1, 2, NA, NA, NA, 3, NA, rep(NA, 
          4)), ncol = 4, nrow = 3, byrow = T)
      expect_error(get_sink_states(mat_nonsquare), "Error: must provide a square transition matrix.")
      mat_square <- matrix(c(NA, 1, 2, NA, NA, NA, 3, NA, rep(NA, 
          8)), ncol = 4, nrow = 4, byrow = T)
      colnames(mat_square) <- c("healthy", "illness", "death", 
          "censored")
      rownames(mat_square) <- c("healthy", "illness", "death", 
          "censored")
      expect_equal(get_sink_states(mat_square), c("death", "censored"))
      expect_equal(get_sink_states(trans.comprisk(3)), paste0("cause", 
          1:3))
      expect_equal(get_sink_states(trans.comprisk(5)), paste0("cause", 
          1:5))
  })
  where 17: eval(code, test_env)
  where 18: eval(code, test_env)
  where 19: 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 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 22: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 23: doTryCatch(return(expr), name, parentenv, handler)
  where 24: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 25: tryCatchList(expr, classes, parentenv, handlers)
  where 26: 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 27: test_code(NULL, exprs, env)
  where 28: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 29: force(code)
  where 30: doWithOneRestart(return(expr), restart)
  where 31: withOneRestart(expr, restarts[[1L]])
  where 32: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 33: 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 34: FUN(X[[i]], ...)
  where 35: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 36: force(code)
  where 37: doWithOneRestart(return(expr), restart)
  where 38: withOneRestart(expr, restarts[[1L]])
  where 39: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 40: 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 41: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 42: 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 43: 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 44: test_check("multistateutils")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (tmat) 
  {
      if (class(tmat) != "matrix") 
          stop("Error: must provide a square transition matrix.")
      if (ncol(tmat) != nrow(tmat)) 
          stop("Error: must provide a square transition matrix.")
      rownames(tmat)[apply(tmat, 1, function(row) all(is.na(row)))]
  }
  <bytecode: 0x3075528>
  <environment: namespace:multistateutils>
   --- function search by body ---
  Function get_sink_states in namespace multistateutils has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 10. Error: get_sink_states correctly returns sink states (@test_utils.R#56)  
  the condition has length > 1
  Backtrace:
   1. testthat::expect_equal(get_sink_states(tmat), "death")
   4. multistateutils:::get_sink_states(tmat)
  
  -- 11. Failure: form_model_matrix returns a matrix (@test_utils.R#198)  --------
  class(out) not equal to "matrix".
  Lengths differ: 2 is not 1
  
  == testthat results  ===========================================================
  [ OK: 133 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 11 ]
  1. Error: cohort_simulation age limit works (@test_cohort.R#63) 
  2. Error: length_of_stay age limit works (@test_lengthofstay.R#96) 
  3. Error: msprep2 produces same output on ebmt3 as msprep (@test_msprep2.R#65) 
  4. Error: msprep2 idcolumn works (@test_msprep2.R#94) 
  5. Error: msprep2 covars guards work (@test_msprep2.R#156) 
  6. Error: msprep2 start_time guards work (@test_msprep2.R#178) 
  7. Error: msprep2 start_states guards work (@test_msprep2.R#216) 
  8. Error: msprep2 works with repeated state entries (@test_msprep2.R#271) 
  9. Error: predict_transitions age limit works (@test_transitionprobs.R#153) 
  1. ...
  
  Error: testthat unit tests failed
  Execution halted