Running 'testthat.R' [41s/37s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library(testthat)
  > library(jstable)
  > 
  > test_check("jstable")
  Independent Sampling design (with replacement)
  svydesign(id = ~1, data = lung)
  Independent Sampling design (with replacement)
  svydesign(id = ~1, data = lung)
  Independent Sampling design (with replacement)
  svydesign(id = ~1, data = lung)
  Independent Sampling design (with replacement)
  subset(data, get(var_subgroup) == .)
  Independent Sampling design (with replacement)
  subset(data, get(var_subgroup) == .)
  Independent Sampling design (with replacement)
  svydesign(id = ~1, data = lung)
  Independent Sampling design (with replacement)
  subset(data, get(var_subgroup) == .)
  Independent Sampling design (with replacement)
  svydesign(id = ~1, data = lung)
  Independent Sampling design (with replacement)
  svydesign(id = ~1, data = lung)
  Independent Sampling design (with replacement)
  subset(data, get(var_subgroup) == .)
  Independent Sampling design (with replacement)
  subset(data, get(var_subgroup) == .)
  Independent Sampling design (with replacement)
  svydesign(id = ~1, data = lung)
  Independent Sampling design (with replacement)
  subset(data, get(var_subgroup) == .)
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  jstable
   --- call from context --- 
  glmshow.display(fit)
   --- call from argument --- 
  if (class(fix.all.unlist) == "character") {
      fix.all.unlist <- t(data.frame(fix.all.unlist))
  }
   --- R stacktrace ---
  where 1 at testthat/test-label.R#9: glmshow.display(fit)
  where 2: eval(code, test_env)
  where 3: eval(code, test_env)
  where 4: 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 5: doTryCatch(return(expr), name, parentenv, handler)
  where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 10: tryCatchList(expr, classes, parentenv, handlers)
  where 11: 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 12: test_code(desc, code, env = parent.frame())
  where 13 at testthat/test-label.R#7: test_that("LabelepiDisplay", {
      fit <- glm(Sepal.Length ~ Sepal.Width + Species, data = iris)
      fit.table <- glmshow.display(fit)
      iris.label <- mk.lev(iris)
      expect_is(LabelepiDisplay(fit.table, label = TRUE, ref = iris.label), 
          "matrix")
  })
  where 14: eval(code, test_env)
  where 15: eval(code, test_env)
  where 16: 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 17: doTryCatch(return(expr), name, parentenv, handler)
  where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 22: tryCatchList(expr, classes, parentenv, handlers)
  where 23: 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 24: test_code(NULL, exprs, env)
  where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 26: force(code)
  where 27: doWithOneRestart(return(expr), restart)
  where 28: withOneRestart(expr, restarts[[1L]])
  where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 30: 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 31: FUN(X[[i]], ...)
  where 32: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 33: force(code)
  where 34: doWithOneRestart(return(expr), restart)
  where 35: withOneRestart(expr, restarts[[1L]])
  where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 37: 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 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 39: 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 40: 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 41: test_check("jstable")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (glm.object, decimal = 2) 
  {
      model <- glm.object
      if (!any(class(model) %in% c("lm", "glm"))) {
          stop("Model not from  GLM")
      }
      xs <- attr(model$terms, "term.labels")
      y <- names(model$model)[1]
      gaussianT <- ifelse(length(grep("gaussian", model$family)) == 
          1, T, F)
      data <- model$data
      if (length(xs) == 0) {
          stop("No independent variable")
      }
      else if (length(xs) == 1) {
          uni <- data.frame(coefNA(stats::glm(as.formula(paste(y, 
              " ~ ", xs)), data = data, family = model$family)))[-1, 
              ]
          rn.uni <- lapply(list(uni), rownames)
          if (gaussianT) {
              summ <- paste(round(uni[, 1], decimal), " (", round(uni[, 
                  1] - 1.96 * uni[, 2], decimal), ",", round(uni[, 
                  1] + 1.96 * uni[, 2], decimal), ")", sep = "")
              uni.res <- matrix(cbind(summ, ifelse(uni[, 4] <= 
                  0.001, "< 0.001", as.character(round(uni[, 4], 
                  decimal + 1)))), nrow = nrow(uni))
              colnames(uni.res) <- c(paste("Coeff.(", 100 - 100 * 
                  0.05, "%CI)", sep = ""), "P value")
          }
          else {
              summ <- paste(round(exp(uni[, 1]), decimal), " (", 
                  round(exp(uni[, 1] - 1.96 * uni[, 2]), decimal), 
                  ",", round(exp(uni[, 1] + 1.96 * uni[, 2]), decimal), 
                  ")", sep = "")
              uni.res <- matrix(cbind(summ, ifelse(uni[, 4] <= 
                  0.001, "< 0.001", as.character(round(uni[, 4], 
                  decimal + 1)))), nrow = nrow(uni))
              colnames(uni.res) <- c(paste("OR.(", 100 - 100 * 
                  0.05, "%CI)", sep = ""), "P value")
          }
          rownames(uni.res) <- rownames(uni)
          res <- uni.res
      }
      else {
          uni <- lapply(xs, function(v) {
              data.frame(coefNA(stats::glm(as.formula(paste(y, 
                  " ~ ", v)), data = data, family = model$family)))[-1, 
                  ]
          })
          rn.uni <- lapply(uni, rownames)
          uni <- Reduce(rbind, uni)
          if (gaussianT) {
              summ <- paste(round(uni[, 1], decimal), " (", round(uni[, 
                  1] - 1.96 * uni[, 2], decimal), ",", round(uni[, 
                  1] + 1.96 * uni[, 2], decimal), ")", sep = "")
              uni.res <- t(rbind(summ, ifelse(uni[, 4] <= 0.001, 
                  "< 0.001", as.character(round(uni[, 4], decimal + 
                    1)))))
              colnames(uni.res) <- c(paste("crude coeff.(", 100 - 
                  100 * 0.05, "%CI)", sep = ""), "crude P value")
              rownames(uni.res) <- rownames(uni)
              mul <- coefNA(model)[-1, ]
              mul.summ <- paste(round(mul[, 1], decimal), " (", 
                  round(mul[, 1] - 1.96 * mul[, 2], decimal), ",", 
                  round(mul[, 1] + 1.96 * mul[, 2], decimal), ")", 
                  sep = "")
              mul.res <- t(rbind(mul.summ, ifelse(mul[, 4] <= 0.001, 
                  "< 0.001", as.character(round(mul[, 4], decimal + 
                    1)))))
              colnames(mul.res) <- c(paste("adj. coeff.(", 100 - 
                  100 * 0.05, "%CI)", sep = ""), "adj. P value")
          }
          else {
              summ <- paste(round(exp(uni[, 1]), decimal), " (", 
                  round(exp(uni[, 1] - 1.96 * uni[, 2]), decimal), 
                  ",", round(exp(uni[, 1] + 1.96 * uni[, 2]), decimal), 
                  ")", sep = "")
              uni.res <- t(rbind(summ, ifelse(uni[, 4] <= 0.001, 
                  "< 0.001", as.character(round(uni[, 4], decimal + 
                    1)))))
              colnames(uni.res) <- c(paste("crude OR.(", 100 - 
                  100 * 0.05, "%CI)", sep = ""), "crude P value")
              rownames(uni.res) <- rownames(uni)
              mul <- coefNA(model)[-1, ]
              mul.summ <- paste(round(exp(mul[, 1]), decimal), 
                  " (", round(exp(mul[, 1] - 1.96 * mul[, 2]), 
                    decimal), ",", round(exp(mul[, 1] + 1.96 * 
                    mul[, 2]), decimal), ")", sep = "")
              mul.res <- t(rbind(mul.summ, ifelse(mul[, 4] <= 0.001, 
                  "< 0.001", as.character(round(mul[, 4], decimal + 
                    1)))))
              colnames(mul.res) <- c(paste("adj. OR.(", 100 - 100 * 
                  0.05, "%CI)", sep = ""), "adj. P value")
          }
          res <- cbind(uni.res[rownames(uni.res) %in% rownames(mul.res), 
              ], mul.res)
          rownames(res) <- rownames(mul)
      }
      fix.all <- res
      fix.all.list <- lapply(1:length(xs), function(x) {
          fix.all[rownames(fix.all) %in% rn.uni[[x]], ]
      })
      varnum.mfac <- which(lapply(fix.all.list, length) > ncol(fix.all))
      lapply(varnum.mfac, function(x) {
          fix.all.list[[x]] <<- rbind(rep(NA, ncol(fix.all)), fix.all.list[[x]])
      })
      fix.all.unlist <- Reduce(rbind, fix.all.list)
      rn.list <- lapply(1:length(xs), function(x) {
          rownames(fix.all)[rownames(fix.all) %in% rn.uni[[x]]]
      })
      varnum.2fac <- which(xs %in% names(model$xlevels)[lapply(model$xlevels, 
          length) == 2])
      lapply(varnum.2fac, function(x) {
          rn.list[[x]] <<- paste(xs[x], ": ", model$xlevels[[xs[x]]][2], 
              " vs ", model$xlevels[[xs[x]]][1], sep = "")
      })
      lapply(varnum.mfac, function(x) {
          rn.list[[x]] <<- c(paste(xs[x], ": ref.=", model$xlevels[[xs[x]]][1], 
              sep = ""), gsub(xs[x], "   ", rn.list[[x]]))
      })
      if (class(fix.all.unlist) == "character") {
          fix.all.unlist <- t(data.frame(fix.all.unlist))
      }
      rownames(fix.all.unlist) <- unlist(rn.list)
      outcome.name <- y
      if (gaussianT) {
          first.line <- paste("Linear regression predicting ", 
              outcome.name, sep = "", "\n")
          last.lines <- paste("No. of observations = ", length(model$y), 
              "\n", "R-squared = ", round(cor(model$y, predict(model))^2, 
                  decimal + 2), "\n", "AIC value = ", round(model$aic, 
                  decimal + 2), "\n", "\n", sep = "")
      }
      else {
          first.line <- paste("Logistic regression predicting ", 
              outcome.name, sep = "", "\n")
          last.lines <- paste("No. of observations = ", length(model$y), 
              "\n", "AIC value = ", round(model$aic, decimal + 
                  2), "\n", "\n", sep = "")
      }
      results <- list(first.line = first.line, table = fix.all.unlist, 
          last.lines = last.lines)
      class(results) <- c("display", "list")
      return(results)
  }
  <bytecode: 0xdc06d00>
  <environment: namespace:jstable>
   --- function search by body ---
  Function glmshow.display in namespace jstable has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 1. Error: LabelepiDisplay (@test-label.R#9)  --------------------------------
  the condition has length > 1
  Backtrace:
   1. jstable::glmshow.display(fit)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  jstable
   --- call from context --- 
  coxme.display(fit)
   --- call from argument --- 
  if (class(fix.all.unlist) == "character") {
      fix.all.unlist = t(data.frame(fix.all.unlist))
  }
   --- R stacktrace ---
  where 1 at testthat/test-label.R#18: coxme.display(fit)
  where 2: eval(code, test_env)
  where 3: eval(code, test_env)
  where 4: 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 5: doTryCatch(return(expr), name, parentenv, handler)
  where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 10: tryCatchList(expr, classes, parentenv, handlers)
  where 11: 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 12: test_code(desc, code, env = parent.frame())
  where 13 at testthat/test-label.R#15: test_that("LabeljsTable", {
      library(coxme)
      fit <- coxme(Surv(time, status) ~ sex + ph.ecog + ph.karno + 
          (1 | inst) + (1 | sex), lung)
      fit.table <- coxme.display(fit)
      lung.label <- mk.lev(lung)
      expect_is(LabeljsMixed(fit.table, ref = lung.label), "list")
  })
  where 14: eval(code, test_env)
  where 15: eval(code, test_env)
  where 16: 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 17: doTryCatch(return(expr), name, parentenv, handler)
  where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 22: tryCatchList(expr, classes, parentenv, handlers)
  where 23: 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 24: test_code(NULL, exprs, env)
  where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 26: force(code)
  where 27: doWithOneRestart(return(expr), restart)
  where 28: withOneRestart(expr, restarts[[1L]])
  where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 30: 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 31: FUN(X[[i]], ...)
  where 32: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 33: force(code)
  where 34: doWithOneRestart(return(expr), restart)
  where 35: withOneRestart(expr, restarts[[1L]])
  where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 37: 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 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 39: 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 40: 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 41: test_check("jstable")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (coxme.obj, dec = 2) 
  {
      model <- coxme.obj
      if (!any(class(model) == "coxme")) {
          stop("Model not from mixed effects Cox model")
      }
      xf <- attr(model$terms, "term.labels")
      if (length(grep("strata", xf)) > 0) {
          xf <- xf[-grep("strata", xf)]
      }
      formula.surv = as.character(model$formulaList$fixed)[2]
      formula.ranef = as.character(model$formulaList$random)
      mdata = data.frame(get(as.character(model$call)[3]))
      if (length(xf) == 1) {
          uni.res = coxmeTable(coxme(as.formula(paste(formula.surv, 
              "~", xf, " + ", formula.ranef, sep = "")), data = mdata))
          rn.uni <- lapply(list(uni.res), rownames)
          fix.all = coxExp(uni.res, dec = dec)
          colnames(fix.all) = c("HR(95%CI)", "P value")
          rownames(fix.all) = names(model$coefficients)
      }
      else {
          unis <- lapply(xf, function(x) {
              coxmeTable(coxme(as.formula(paste(formula.surv, "~", 
                  x, " + ", formula.ranef, sep = "")), data = mdata))
          })
          rn.uni <- lapply(unis, rownames)
          unis2 <- Reduce(rbind, unis)
          uni.res <- unis2
          fix.all = cbind(coxExp(uni.res, dec = dec), coxExp(coxmeTable(model), 
              dec = dec))
          colnames(fix.all) = c("crude HR(95%CI)", "crude P value", 
              "adj. HR(95%CI)", "adj. P value")
          rownames(fix.all) = names(model$coefficients)
      }
      fix.all.list = lapply(1:length(xf), function(x) {
          fix.all[rownames(fix.all) %in% rn.uni[[x]], ]
      })
      varnum.mfac = which(lapply(fix.all.list, length) > ncol(fix.all))
      lapply(varnum.mfac, function(x) {
          fix.all.list[[x]] <<- rbind(rep(NA, ncol(fix.all)), fix.all.list[[x]])
      })
      fix.all.unlist = Reduce(rbind, fix.all.list)
      rn.list = lapply(1:length(xf), function(x) {
          rownames(fix.all)[rownames(fix.all) %in% rn.uni[[x]]]
      })
      varnum.2fac = which(lapply(xf, function(x) {
          length(sapply(mdata, levels)[[x]])
      }) == 2)
      lapply(varnum.2fac, function(x) {
          rn.list[[x]] <<- paste(xf[x], ": ", levels(mdata[, xf[x]])[2], 
              " vs ", levels(mdata[, xf[x]])[1], sep = "")
      })
      lapply(varnum.mfac, function(x) {
          rn.list[[x]] <<- c(paste(xf[x], ": ref.=", levels(mdata[, 
              xf[x]])[1], sep = ""), gsub(xf[x], "   ", rn.list[[x]]))
      })
      if (class(fix.all.unlist) == "character") {
          fix.all.unlist = t(data.frame(fix.all.unlist))
      }
      rownames(fix.all.unlist) = unlist(rn.list)
      pv.colnum = which(colnames(fix.all.unlist) %in% c("P value", 
          "crude P value", "adj. P value"))
      for (i in pv.colnum) {
          fix.all.unlist[, i] = ifelse(as.numeric(fix.all.unlist[, 
              i]) < 0.001, "< 0.001", round(as.numeric(fix.all.unlist[, 
              i]), dec + 1))
      }
      ranef.out = lapply(model$vcoef, function(x) {
          round(x, dec)
      })
      ranef.mat = cbind(c(NA, unlist(ranef.out)), matrix(NA, length(unlist(ranef.out)) + 
          1, ncol(fix.all) - 1))
      rownames(ranef.mat) = c("Random effect", paste(names(ranef.out), 
          "(", unlist(lapply(ranef.out, names)), ")", sep = ""))
      no.grp = unlist(lapply(model$frail, length))
      no.obs = model$n[2]
      no.event = model$n[1]
      metric.mat = cbind(c(NA, no.grp, no.obs, no.event), matrix(NA, 
          length(no.grp) + 3, ncol(fix.all) - 1))
      rownames(metric.mat) = c(NA, paste("No. of groups(", names(no.grp), 
          ")", sep = ""), "No. of observations", "No. of events")
      surv.string <- as.character(attr(model$terms, "variables")[[2]])
      time.var.name <- surv.string[2]
      status.var.name <- surv.string[3]
      intro <- paste("Mixed effects Cox model on time ('", time.var.name, 
          "') to event ('", status.var.name, "')", " - Group ", 
          paste(names(model$vcoef), collapse = ", "), sep = "")
      var.names0 <- attr(model$terms, "term.labels")
      if (length(grep("strata", var.names0)) > 0) {
          intro <- paste(intro, " with '", var.names0[grep("strata", 
              var.names0)], "'", sep = "")
      }
      return(list(table = fix.all.unlist, ranef = ranef.mat, metric = metric.mat, 
          caption = intro))
  }
  <bytecode: 0xdb1d8b0>
  <environment: namespace:jstable>
   --- function search by body ---
  Function coxme.display in namespace jstable has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 2. Error: LabeljsTable (@test-label.R#18)  ----------------------------------
  the condition has length > 1
  Backtrace:
   1. jstable::coxme.display(fit)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  jstable
   --- call from context --- 
  cox2.display(fit)
   --- call from argument --- 
  if (class(fix.all.unlist) == "character") {
      fix.all.unlist <- t(data.frame(fix.all.unlist))
  }
   --- R stacktrace ---
  where 1 at testthat/test-label.R#27: cox2.display(fit)
  where 2: eval(code, test_env)
  where 3: eval(code, test_env)
  where 4: 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 5: doTryCatch(return(expr), name, parentenv, handler)
  where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 10: tryCatchList(expr, classes, parentenv, handlers)
  where 11: 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 12: test_code(desc, code, env = parent.frame())
  where 13 at testthat/test-label.R#24: test_that("LabeljsCox", {
      library(survival)
      fit <- coxph(Surv(time, status) ~ sex + ph.ecog + ph.karno + 
          cluster(inst), data = lung, model = TRUE)
      fit.table <- cox2.display(fit)
      lung.label <- mk.lev(lung)
      LabeljsCox(fit.table, ref = lung.label)
      expect_is(LabeljsCox(fit.table, ref = lung.label), "list")
  })
  where 14: eval(code, test_env)
  where 15: eval(code, test_env)
  where 16: 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 17: doTryCatch(return(expr), name, parentenv, handler)
  where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 22: tryCatchList(expr, classes, parentenv, handlers)
  where 23: 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 24: test_code(NULL, exprs, env)
  where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 26: force(code)
  where 27: doWithOneRestart(return(expr), restart)
  where 28: withOneRestart(expr, restarts[[1L]])
  where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 30: 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 31: FUN(X[[i]], ...)
  where 32: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 33: force(code)
  where 34: doWithOneRestart(return(expr), restart)
  where 35: withOneRestart(expr, restarts[[1L]])
  where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 37: 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 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 39: 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 40: 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 41: test_check("jstable")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (cox.obj.withmodel, dec = 2) 
  {
      model <- cox.obj.withmodel
      if (!any(class(model) == "coxph")) {
          stop("Model not from Cox model")
      }
      xf <- attr(model$terms, "term.labels")
      xf.old <- xf
      xc <- NULL
      xc.vn <- NULL
      mtype <- "normal"
      if (length(grep("strata", xf)) > 0) {
          xf <- xf[-grep("strata", xf)]
      }
      else if (length(grep("frailty\\(", xf)) > 0) {
          xf <- xf[-grep("frailty\\(", xf)]
          mtype <- "frailty"
          xc <- setdiff(xf.old, xf)
          xc.vn <- strsplit(strsplit(xc, "frailty\\(")[[1]][2], 
              "\\)")[[1]][1]
      }
      else if (!(is.null(model$call$cluster))) {
          mtype <- "cluster"
          xc <- as.character(model$call$cluster)
          xc.vn <- xc
      }
      formula.surv <- as.character(model$formula)[2]
      formula.ranef <- paste(" + ", xc, sep = "")
      mdata <- model$model
      if (length(xc) == 0) {
          formula.ranef <- NULL
      }
      else {
          names(mdata)[names(mdata) == xc] <- xc.vn
      }
      if (length(xf) == 1) {
          uni.res <- data.frame(summary(model)$coefficients)
          rn.uni <- lapply(list(uni.res), rownames)
          names(uni.res)[ncol(uni.res)] <- "p"
          uni.res2 <- NULL
          if (mtype == "normal") {
              uni.res2 <- uni.res[, c(1, 3, 4, 5)]
          }
          else if (mtype == "cluster") {
              uni.res2 <- uni.res[, c(1, 4, 5, 6)]
          }
          else {
              uni.res2 <- uni.res[-nrow(uni.res), c(1, 3, 4, 6)]
          }
          fix.all <- coxExp(uni.res2, dec = dec)
          colnames(fix.all) <- c("HR(95%CI)", "P value")
          rownames(fix.all) <- names(model$coefficients)
      }
      else {
          basemodel <- update(model, formula(paste(c(". ~ .", xf), 
              collapse = " - ")))
          unis <- lapply(xf, function(x) {
              newfit <- update(basemodel, formula(paste0(". ~ . +", 
                  x)))
              uni.res <- data.frame(summary(newfit)$coefficients)
              uni.res <- uni.res[c(2:nrow(uni.res), 1), ]
              names(uni.res)[ncol(uni.res)] <- "p"
              uni.res2 <- NULL
              if (mtype == "normal") {
                  uni.res2 <- uni.res[, c(1, 3, 4, 5)]
              }
              else if (mtype == "cluster") {
                  uni.res2 <- uni.res[, c(1, 4, 5, 6)]
              }
              else {
                  uni.res2 <- uni.res[-nrow(uni.res), c(1, 3, 4, 
                    6)]
              }
              return(uni.res2)
          })
          rn.uni <- lapply(unis, rownames)
          unis2 <- Reduce(rbind, unis)
          uni.res <- unis2
          mul.res <- data.frame(coefNA(model))
          uni.res <- uni.res[rownames(uni.res) %in% rownames(mul.res), 
              ]
          colnames(mul.res)[ncol(mul.res)] <- "p"
          fix.all <- cbind(coxExp(uni.res, dec = dec), coxExp(mul.res[rownames(uni.res), 
              names(uni.res)], dec = dec))
          colnames(fix.all) <- c("crude HR(95%CI)", "crude P value", 
              "adj. HR(95%CI)", "adj. P value")
          rownames(fix.all) <- rownames(uni.res)
      }
      fix.all.list <- lapply(1:length(xf), function(x) {
          fix.all[rownames(fix.all) %in% rn.uni[[x]], ]
      })
      varnum.mfac <- which(lapply(fix.all.list, length) > ncol(fix.all))
      lapply(varnum.mfac, function(x) {
          fix.all.list[[x]] <<- rbind(rep(NA, ncol(fix.all)), fix.all.list[[x]])
      })
      fix.all.unlist <- Reduce(rbind, fix.all.list)
      rn.list <- lapply(1:length(xf), function(x) {
          rownames(fix.all)[rownames(fix.all) %in% rn.uni[[x]]]
      })
      varnum.2fac <- which(lapply(xf, function(x) {
          length(sapply(mdata, levels)[[x]])
      }) == 2)
      lapply(varnum.2fac, function(x) {
          rn.list[[x]] <<- paste(xf[x], ": ", levels(mdata[, xf[x]])[2], 
              " vs ", levels(mdata[, xf[x]])[1], sep = "")
      })
      lapply(varnum.mfac, function(x) {
          rn.list[[x]] <<- c(paste(xf[x], ": ref.=", levels(mdata[, 
              xf[x]])[1], sep = ""), gsub(xf[x], "   ", rn.list[[x]]))
      })
      if (class(fix.all.unlist) == "character") {
          fix.all.unlist <- t(data.frame(fix.all.unlist))
      }
      rownames(fix.all.unlist) <- unlist(rn.list)
      pv.colnum <- which(colnames(fix.all.unlist) %in% c("P value", 
          "crude P value", "adj. P value"))
      for (i in pv.colnum) {
          fix.all.unlist[, i] <- ifelse(as.numeric(fix.all.unlist[, 
              i]) < 0.001, "< 0.001", round(as.numeric(fix.all.unlist[, 
              i]), dec + 1))
      }
      ranef.mat = NULL
      if (mtype == "cluster") {
          ranef.mat <- cbind(c(NA, NA), matrix(NA, length(xc) + 
              1, ncol(fix.all) - 1))
          clname <- c("cluster", xc)
          cvname <- strsplit(paste(clname[-1], collapse = "("), 
              "\\)")[[1]]
          cvname <- paste(cvname[length(cvname)], collapse = ")")
          rownames(ranef.mat) <- c(clname[1], cvname)
      }
      else if (mtype == "frailty") {
          ranef.mat <- cbind(c(NA, NA), matrix(NA, length(xc) + 
              1, ncol(fix.all) - 1))
          clname <- strsplit(xc, "\\(")[[1]]
          cvname <- strsplit(paste(clname[-1], collapse = "("), 
              "\\)")[[1]]
          cvname <- paste(cvname[length(cvname)], collapse = ")")
          rownames(ranef.mat) <- c(clname[1], cvname)
      }
      no.obs = model$n
      no.event = model$nevent
      metric.mat = cbind(c(NA, no.obs, no.event), matrix(NA, 3, 
          ncol(fix.all) - 1))
      rownames(metric.mat) = c(NA, "No. of observations", "No. of events")
      surv.string <- as.character(attr(model$terms, "variables")[[2]])
      time.var.name <- surv.string[2]
      status.var.name <- surv.string[3]
      intro <- paste("Cox model on time ('", time.var.name, "') to event ('", 
          status.var.name, "')", sep = "")
      if (mtype == "cluster") {
          intro <- paste("Marginal", intro, "- Group", cvname)
      }
      else if (mtype == "frailty") {
          intro <- paste("Frailty", intro, "- Group", cvname)
      }
      var.names0 <- attr(model$terms, "term.labels")
      if (length(grep("strata", var.names0)) > 0) {
          intro <- paste(intro, " with '", var.names0[grep("strata", 
              var.names0)], "'", sep = "")
      }
      if (is.null(ranef.mat)) {
          return(list(table = fix.all.unlist, metric = metric.mat, 
              caption = intro))
      }
      else {
          return(list(table = fix.all.unlist, ranef = ranef.mat, 
              metric = metric.mat, caption = intro))
      }
  }
  <bytecode: 0xdac65f0>
  <environment: namespace:jstable>
   --- function search by body ---
  Function cox2.display in namespace jstable has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 3. Error: LabeljsCox (@test-label.R#27)  ------------------------------------
  the condition has length > 1
  Backtrace:
   1. jstable::cox2.display(fit)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  jstable
   --- call from context --- 
  glmshow.display(glm(mpg ~ cyl + disp, data = mtcars))
   --- call from argument --- 
  if (class(fix.all.unlist) == "character") {
      fix.all.unlist <- t(data.frame(fix.all.unlist))
  }
   --- R stacktrace ---
  where 1: glmshow.display(glm(mpg ~ cyl + disp, data = mtcars))
  where 2: eval_bare(expr, quo_get_env(quo))
  where 3: quasi_label(enquo(object), label, arg = "object")
  where 4 at testthat/test-regtable.R#6: expect_is(glmshow.display(glm(mpg ~ cyl + disp, data = mtcars)), 
      "display")
  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-regtable.R#4: test_that("Run glmshow.display", {
      expect_is(glmshow.display(glm(mpg ~ cyl, data = mtcars)), 
          "display")
      expect_is(glmshow.display(glm(mpg ~ cyl + disp, data = mtcars)), 
          "display")
      expect_is(glmshow.display(glm(am ~ cyl, data = mtcars, family = "binomial")), 
          "display")
      expect_is(glmshow.display(glm(am ~ cyl + disp, data = mtcars, 
          family = "binomial")), "display")
  })
  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("jstable")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (glm.object, decimal = 2) 
  {
      model <- glm.object
      if (!any(class(model) %in% c("lm", "glm"))) {
          stop("Model not from  GLM")
      }
      xs <- attr(model$terms, "term.labels")
      y <- names(model$model)[1]
      gaussianT <- ifelse(length(grep("gaussian", model$family)) == 
          1, T, F)
      data <- model$data
      if (length(xs) == 0) {
          stop("No independent variable")
      }
      else if (length(xs) == 1) {
          uni <- data.frame(coefNA(stats::glm(as.formula(paste(y, 
              " ~ ", xs)), data = data, family = model$family)))[-1, 
              ]
          rn.uni <- lapply(list(uni), rownames)
          if (gaussianT) {
              summ <- paste(round(uni[, 1], decimal), " (", round(uni[, 
                  1] - 1.96 * uni[, 2], decimal), ",", round(uni[, 
                  1] + 1.96 * uni[, 2], decimal), ")", sep = "")
              uni.res <- matrix(cbind(summ, ifelse(uni[, 4] <= 
                  0.001, "< 0.001", as.character(round(uni[, 4], 
                  decimal + 1)))), nrow = nrow(uni))
              colnames(uni.res) <- c(paste("Coeff.(", 100 - 100 * 
                  0.05, "%CI)", sep = ""), "P value")
          }
          else {
              summ <- paste(round(exp(uni[, 1]), decimal), " (", 
                  round(exp(uni[, 1] - 1.96 * uni[, 2]), decimal), 
                  ",", round(exp(uni[, 1] + 1.96 * uni[, 2]), decimal), 
                  ")", sep = "")
              uni.res <- matrix(cbind(summ, ifelse(uni[, 4] <= 
                  0.001, "< 0.001", as.character(round(uni[, 4], 
                  decimal + 1)))), nrow = nrow(uni))
              colnames(uni.res) <- c(paste("OR.(", 100 - 100 * 
                  0.05, "%CI)", sep = ""), "P value")
          }
          rownames(uni.res) <- rownames(uni)
          res <- uni.res
      }
      else {
          uni <- lapply(xs, function(v) {
              data.frame(coefNA(stats::glm(as.formula(paste(y, 
                  " ~ ", v)), data = data, family = model$family)))[-1, 
                  ]
          })
          rn.uni <- lapply(uni, rownames)
          uni <- Reduce(rbind, uni)
          if (gaussianT) {
              summ <- paste(round(uni[, 1], decimal), " (", round(uni[, 
                  1] - 1.96 * uni[, 2], decimal), ",", round(uni[, 
                  1] + 1.96 * uni[, 2], decimal), ")", sep = "")
              uni.res <- t(rbind(summ, ifelse(uni[, 4] <= 0.001, 
                  "< 0.001", as.character(round(uni[, 4], decimal + 
                    1)))))
              colnames(uni.res) <- c(paste("crude coeff.(", 100 - 
                  100 * 0.05, "%CI)", sep = ""), "crude P value")
              rownames(uni.res) <- rownames(uni)
              mul <- coefNA(model)[-1, ]
              mul.summ <- paste(round(mul[, 1], decimal), " (", 
                  round(mul[, 1] - 1.96 * mul[, 2], decimal), ",", 
                  round(mul[, 1] + 1.96 * mul[, 2], decimal), ")", 
                  sep = "")
              mul.res <- t(rbind(mul.summ, ifelse(mul[, 4] <= 0.001, 
                  "< 0.001", as.character(round(mul[, 4], decimal + 
                    1)))))
              colnames(mul.res) <- c(paste("adj. coeff.(", 100 - 
                  100 * 0.05, "%CI)", sep = ""), "adj. P value")
          }
          else {
              summ <- paste(round(exp(uni[, 1]), decimal), " (", 
                  round(exp(uni[, 1] - 1.96 * uni[, 2]), decimal), 
                  ",", round(exp(uni[, 1] + 1.96 * uni[, 2]), decimal), 
                  ")", sep = "")
              uni.res <- t(rbind(summ, ifelse(uni[, 4] <= 0.001, 
                  "< 0.001", as.character(round(uni[, 4], decimal + 
                    1)))))
              colnames(uni.res) <- c(paste("crude OR.(", 100 - 
                  100 * 0.05, "%CI)", sep = ""), "crude P value")
              rownames(uni.res) <- rownames(uni)
              mul <- coefNA(model)[-1, ]
              mul.summ <- paste(round(exp(mul[, 1]), decimal), 
                  " (", round(exp(mul[, 1] - 1.96 * mul[, 2]), 
                    decimal), ",", round(exp(mul[, 1] + 1.96 * 
                    mul[, 2]), decimal), ")", sep = "")
              mul.res <- t(rbind(mul.summ, ifelse(mul[, 4] <= 0.001, 
                  "< 0.001", as.character(round(mul[, 4], decimal + 
                    1)))))
              colnames(mul.res) <- c(paste("adj. OR.(", 100 - 100 * 
                  0.05, "%CI)", sep = ""), "adj. P value")
          }
          res <- cbind(uni.res[rownames(uni.res) %in% rownames(mul.res), 
              ], mul.res)
          rownames(res) <- rownames(mul)
      }
      fix.all <- res
      fix.all.list <- lapply(1:length(xs), function(x) {
          fix.all[rownames(fix.all) %in% rn.uni[[x]], ]
      })
      varnum.mfac <- which(lapply(fix.all.list, length) > ncol(fix.all))
      lapply(varnum.mfac, function(x) {
          fix.all.list[[x]] <<- rbind(rep(NA, ncol(fix.all)), fix.all.list[[x]])
      })
      fix.all.unlist <- Reduce(rbind, fix.all.list)
      rn.list <- lapply(1:length(xs), function(x) {
          rownames(fix.all)[rownames(fix.all) %in% rn.uni[[x]]]
      })
      varnum.2fac <- which(xs %in% names(model$xlevels)[lapply(model$xlevels, 
          length) == 2])
      lapply(varnum.2fac, function(x) {
          rn.list[[x]] <<- paste(xs[x], ": ", model$xlevels[[xs[x]]][2], 
              " vs ", model$xlevels[[xs[x]]][1], sep = "")
      })
      lapply(varnum.mfac, function(x) {
          rn.list[[x]] <<- c(paste(xs[x], ": ref.=", model$xlevels[[xs[x]]][1], 
              sep = ""), gsub(xs[x], "   ", rn.list[[x]]))
      })
      if (class(fix.all.unlist) == "character") {
          fix.all.unlist <- t(data.frame(fix.all.unlist))
      }
      rownames(fix.all.unlist) <- unlist(rn.list)
      outcome.name <- y
      if (gaussianT) {
          first.line <- paste("Linear regression predicting ", 
              outcome.name, sep = "", "\n")
          last.lines <- paste("No. of observations = ", length(model$y), 
              "\n", "R-squared = ", round(cor(model$y, predict(model))^2, 
                  decimal + 2), "\n", "AIC value = ", round(model$aic, 
                  decimal + 2), "\n", "\n", sep = "")
      }
      else {
          first.line <- paste("Logistic regression predicting ", 
              outcome.name, sep = "", "\n")
          last.lines <- paste("No. of observations = ", length(model$y), 
              "\n", "AIC value = ", round(model$aic, decimal + 
                  2), "\n", "\n", sep = "")
      }
      results <- list(first.line = first.line, table = fix.all.unlist, 
          last.lines = last.lines)
      class(results) <- c("display", "list")
      return(results)
  }
  <bytecode: 0xdc06d00>
  <environment: namespace:jstable>
   --- function search by body ---
  Function glmshow.display in namespace jstable has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 4. Error: Run glmshow.display (@test-regtable.R#6)  -------------------------
  the condition has length > 1
  Backtrace:
   1. testthat::expect_is(...)
   4. jstable::glmshow.display(glm(mpg ~ cyl + disp, data = mtcars))
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  jstable
   --- call from context --- 
  cox2.display(fit0)
   --- call from argument --- 
  if (class(fix.all.unlist) == "character") {
      fix.all.unlist <- t(data.frame(fix.all.unlist))
  }
   --- R stacktrace ---
  where 1: cox2.display(fit0)
  where 2: eval_bare(expr, quo_get_env(quo))
  where 3: quasi_label(enquo(object), label, arg = "object")
  where 4 at testthat/test-regtable.R#17: expect_is(cox2.display(fit0), "list")
  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-regtable.R#11: test_that("Run cox2.display", {
      library(survival)
      data(lung)
      fit0 <- coxph(Surv(time, status) ~ ph.ecog + age, data = lung, 
          model = TRUE)
      fit1 <- coxph(Surv(time, status) ~ ph.ecog + age + cluster(inst), 
          data = lung, model = TRUE)
      fit2 <- coxph(Surv(time, status) ~ ph.ecog + age + frailty(inst), 
          data = lung, model = TRUE)
      expect_is(cox2.display(fit0), "list")
      expect_is(cox2.display(fit1), "list")
      expect_is(cox2.display(fit2), "list")
  })
  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("jstable")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (cox.obj.withmodel, dec = 2) 
  {
      model <- cox.obj.withmodel
      if (!any(class(model) == "coxph")) {
          stop("Model not from Cox model")
      }
      xf <- attr(model$terms, "term.labels")
      xf.old <- xf
      xc <- NULL
      xc.vn <- NULL
      mtype <- "normal"
      if (length(grep("strata", xf)) > 0) {
          xf <- xf[-grep("strata", xf)]
      }
      else if (length(grep("frailty\\(", xf)) > 0) {
          xf <- xf[-grep("frailty\\(", xf)]
          mtype <- "frailty"
          xc <- setdiff(xf.old, xf)
          xc.vn <- strsplit(strsplit(xc, "frailty\\(")[[1]][2], 
              "\\)")[[1]][1]
      }
      else if (!(is.null(model$call$cluster))) {
          mtype <- "cluster"
          xc <- as.character(model$call$cluster)
          xc.vn <- xc
      }
      formula.surv <- as.character(model$formula)[2]
      formula.ranef <- paste(" + ", xc, sep = "")
      mdata <- model$model
      if (length(xc) == 0) {
          formula.ranef <- NULL
      }
      else {
          names(mdata)[names(mdata) == xc] <- xc.vn
      }
      if (length(xf) == 1) {
          uni.res <- data.frame(summary(model)$coefficients)
          rn.uni <- lapply(list(uni.res), rownames)
          names(uni.res)[ncol(uni.res)] <- "p"
          uni.res2 <- NULL
          if (mtype == "normal") {
              uni.res2 <- uni.res[, c(1, 3, 4, 5)]
          }
          else if (mtype == "cluster") {
              uni.res2 <- uni.res[, c(1, 4, 5, 6)]
          }
          else {
              uni.res2 <- uni.res[-nrow(uni.res), c(1, 3, 4, 6)]
          }
          fix.all <- coxExp(uni.res2, dec = dec)
          colnames(fix.all) <- c("HR(95%CI)", "P value")
          rownames(fix.all) <- names(model$coefficients)
      }
      else {
          basemodel <- update(model, formula(paste(c(". ~ .", xf), 
              collapse = " - ")))
          unis <- lapply(xf, function(x) {
              newfit <- update(basemodel, formula(paste0(". ~ . +", 
                  x)))
              uni.res <- data.frame(summary(newfit)$coefficients)
              uni.res <- uni.res[c(2:nrow(uni.res), 1), ]
              names(uni.res)[ncol(uni.res)] <- "p"
              uni.res2 <- NULL
              if (mtype == "normal") {
                  uni.res2 <- uni.res[, c(1, 3, 4, 5)]
              }
              else if (mtype == "cluster") {
                  uni.res2 <- uni.res[, c(1, 4, 5, 6)]
              }
              else {
                  uni.res2 <- uni.res[-nrow(uni.res), c(1, 3, 4, 
                    6)]
              }
              return(uni.res2)
          })
          rn.uni <- lapply(unis, rownames)
          unis2 <- Reduce(rbind, unis)
          uni.res <- unis2
          mul.res <- data.frame(coefNA(model))
          uni.res <- uni.res[rownames(uni.res) %in% rownames(mul.res), 
              ]
          colnames(mul.res)[ncol(mul.res)] <- "p"
          fix.all <- cbind(coxExp(uni.res, dec = dec), coxExp(mul.res[rownames(uni.res), 
              names(uni.res)], dec = dec))
          colnames(fix.all) <- c("crude HR(95%CI)", "crude P value", 
              "adj. HR(95%CI)", "adj. P value")
          rownames(fix.all) <- rownames(uni.res)
      }
      fix.all.list <- lapply(1:length(xf), function(x) {
          fix.all[rownames(fix.all) %in% rn.uni[[x]], ]
      })
      varnum.mfac <- which(lapply(fix.all.list, length) > ncol(fix.all))
      lapply(varnum.mfac, function(x) {
          fix.all.list[[x]] <<- rbind(rep(NA, ncol(fix.all)), fix.all.list[[x]])
      })
      fix.all.unlist <- Reduce(rbind, fix.all.list)
      rn.list <- lapply(1:length(xf), function(x) {
          rownames(fix.all)[rownames(fix.all) %in% rn.uni[[x]]]
      })
      varnum.2fac <- which(lapply(xf, function(x) {
          length(sapply(mdata, levels)[[x]])
      }) == 2)
      lapply(varnum.2fac, function(x) {
          rn.list[[x]] <<- paste(xf[x], ": ", levels(mdata[, xf[x]])[2], 
              " vs ", levels(mdata[, xf[x]])[1], sep = "")
      })
      lapply(varnum.mfac, function(x) {
          rn.list[[x]] <<- c(paste(xf[x], ": ref.=", levels(mdata[, 
              xf[x]])[1], sep = ""), gsub(xf[x], "   ", rn.list[[x]]))
      })
      if (class(fix.all.unlist) == "character") {
          fix.all.unlist <- t(data.frame(fix.all.unlist))
      }
      rownames(fix.all.unlist) <- unlist(rn.list)
      pv.colnum <- which(colnames(fix.all.unlist) %in% c("P value", 
          "crude P value", "adj. P value"))
      for (i in pv.colnum) {
          fix.all.unlist[, i] <- ifelse(as.numeric(fix.all.unlist[, 
              i]) < 0.001, "< 0.001", round(as.numeric(fix.all.unlist[, 
              i]), dec + 1))
      }
      ranef.mat = NULL
      if (mtype == "cluster") {
          ranef.mat <- cbind(c(NA, NA), matrix(NA, length(xc) + 
              1, ncol(fix.all) - 1))
          clname <- c("cluster", xc)
          cvname <- strsplit(paste(clname[-1], collapse = "("), 
              "\\)")[[1]]
          cvname <- paste(cvname[length(cvname)], collapse = ")")
          rownames(ranef.mat) <- c(clname[1], cvname)
      }
      else if (mtype == "frailty") {
          ranef.mat <- cbind(c(NA, NA), matrix(NA, length(xc) + 
              1, ncol(fix.all) - 1))
          clname <- strsplit(xc, "\\(")[[1]]
          cvname <- strsplit(paste(clname[-1], collapse = "("), 
              "\\)")[[1]]
          cvname <- paste(cvname[length(cvname)], collapse = ")")
          rownames(ranef.mat) <- c(clname[1], cvname)
      }
      no.obs = model$n
      no.event = model$nevent
      metric.mat = cbind(c(NA, no.obs, no.event), matrix(NA, 3, 
          ncol(fix.all) - 1))
      rownames(metric.mat) = c(NA, "No. of observations", "No. of events")
      surv.string <- as.character(attr(model$terms, "variables")[[2]])
      time.var.name <- surv.string[2]
      status.var.name <- surv.string[3]
      intro <- paste("Cox model on time ('", time.var.name, "') to event ('", 
          status.var.name, "')", sep = "")
      if (mtype == "cluster") {
          intro <- paste("Marginal", intro, "- Group", cvname)
      }
      else if (mtype == "frailty") {
          intro <- paste("Frailty", intro, "- Group", cvname)
      }
      var.names0 <- attr(model$terms, "term.labels")
      if (length(grep("strata", var.names0)) > 0) {
          intro <- paste(intro, " with '", var.names0[grep("strata", 
              var.names0)], "'", sep = "")
      }
      if (is.null(ranef.mat)) {
          return(list(table = fix.all.unlist, metric = metric.mat, 
              caption = intro))
      }
      else {
          return(list(table = fix.all.unlist, ranef = ranef.mat, 
              metric = metric.mat, caption = intro))
      }
  }
  <bytecode: 0xdac65f0>
  <environment: namespace:jstable>
   --- function search by body ---
  Function cox2.display in namespace jstable has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 5. Error: Run cox2.display (@test-regtable.R#17)  ---------------------------
  the condition has length > 1
  Backtrace:
   1. testthat::expect_is(cox2.display(fit0), "list")
   4. jstable::cox2.display(fit0)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  jstable
   --- call from context --- 
  svyregress.display(ds, decimal = 3)
   --- call from argument --- 
  if (class(fix.all.unlist) == "character") {
      fix.all.unlist <- t(data.frame(fix.all.unlist))
  }
   --- R stacktrace ---
  where 1: svyregress.display(ds, decimal = 3)
  where 2: eval_bare(expr, quo_get_env(quo))
  where 3: quasi_label(enquo(object), label, arg = "object")
  where 4 at testthat/test-regtable.R#29: expect_is(svyregress.display(ds, decimal = 3), "display")
  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-regtable.R#23: test_that("Run svyglm.display", {
      library(survey)
      data(api)
      apistrat$tt = c(rep(1, 20), rep(0, nrow(apistrat) - 20))
      dstrat <- svydesign(id = ~1, strata = ~stype, weights = ~pw, 
          data = apistrat, fpc = ~fpc)
      ds <- svyglm(api00 ~ ell + meals, design = dstrat)
      expect_is(svyregress.display(ds, decimal = 3), "display")
      expect_is(svyregress.display(svyglm(api00 ~ ell, design = dstrat), 
          decimal = 3), "display")
      ds2 <- svyglm(tt ~ ell + meals + cname + mobility, design = dstrat, 
          family = quasibinomial())
      expect_is(svyregress.display(ds2, decimal = 3), "display")
  })
  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("jstable")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (svyglm.obj, decimal = 2) 
  {
      model <- svyglm.obj
      design.model <- model$survey.design
      xs <- attr(model$terms, "term.labels")
      y <- names(model$model)[1]
      gaussianT <- ifelse(length(grep("gaussian", model$family)) == 
          1, T, F)
      if (length(xs) == 0) {
          stop("No independent variable")
      }
      else if (length(xs) == 1) {
          uni <- data.frame(coefNA(survey::svyglm(as.formula(paste(y, 
              " ~ ", xs)), design = design.model, family = model$family)))[-1, 
              ]
          rn.uni <- lapply(list(uni), rownames)
          if (gaussianT) {
              summ <- paste(round(uni[, 1], decimal), " (", round(uni[, 
                  1] - 1.96 * uni[, 2], decimal), ",", round(uni[, 
                  1] + 1.96 * uni[, 2], decimal), ")", sep = "")
              uni.res <- matrix(cbind(summ, ifelse(uni[, 4] <= 
                  0.001, "< 0.001", as.character(round(uni[, 4], 
                  decimal + 1)))), nrow = nrow(uni))
              colnames(uni.res) <- c(paste("Coeff.(", 100 - 100 * 
                  0.05, "%CI)", sep = ""), "P value")
          }
          else {
              summ <- paste(round(exp(uni[, 1]), decimal), " (", 
                  round(exp(uni[, 1] - 1.96 * uni[, 2]), decimal), 
                  ",", round(exp(uni[, 1] + 1.96 * uni[, 2]), decimal), 
                  ")", sep = "")
              uni.res <- matrix(cbind(summ, ifelse(uni[, 4] <= 
                  0.001, "< 0.001", as.character(round(uni[, 4], 
                  decimal + 1)))), nrow = nrow(uni))
              colnames(uni.res) <- c(paste("OR.(", 100 - 100 * 
                  0.05, "%CI)", sep = ""), "P value")
          }
          rownames(uni.res) <- rownames(uni)
          res <- uni.res
      }
      else {
          uni <- lapply(xs, function(v) {
              data.frame(coefNA(survey::svyglm(as.formula(paste(y, 
                  " ~ ", v)), design = design.model, family = model$family)))[-1, 
                  ]
          })
          rn.uni <- lapply(uni, rownames)
          uni <- Reduce(rbind, uni)
          if (gaussianT) {
              summ <- paste(round(uni[, 1], decimal), " (", round(uni[, 
                  1] - 1.96 * uni[, 2], decimal), ",", round(uni[, 
                  1] + 1.96 * uni[, 2], decimal), ")", sep = "")
              uni.res <- t(rbind(summ, ifelse(uni[, 4] <= 0.001, 
                  "< 0.001", as.character(round(uni[, 4], decimal + 
                    1)))))
              colnames(uni.res) <- c(paste("crude coeff.(", 100 - 
                  100 * 0.05, "%CI)", sep = ""), "crude P value")
              rownames(uni.res) <- rownames(uni)
              mul <- coefNA(model)[-1, ]
              mul.summ <- paste(round(mul[, 1], decimal), " (", 
                  round(mul[, 1] - 1.96 * mul[, 2], decimal), ",", 
                  round(mul[, 1] + 1.96 * mul[, 2], decimal), ")", 
                  sep = "")
              mul.res <- t(rbind(mul.summ, ifelse(mul[, 4] <= 0.001, 
                  "< 0.001", as.character(round(mul[, 4], decimal + 
                    1)))))
              colnames(mul.res) <- c(paste("adj. coeff.(", 100 - 
                  100 * 0.05, "%CI)", sep = ""), "adj. P value")
          }
          else {
              summ <- paste(round(exp(uni[, 1]), decimal), " (", 
                  round(exp(uni[, 1] - 1.96 * uni[, 2]), decimal), 
                  ",", round(exp(uni[, 1] + 1.96 * uni[, 2]), decimal), 
                  ")", sep = "")
              uni.res <- t(rbind(summ, ifelse(uni[, 4] <= 0.001, 
                  "< 0.001", as.character(round(uni[, 4], decimal + 
                    1)))))
              colnames(uni.res) <- c(paste("crude OR.(", 100 - 
                  100 * 0.05, "%CI)", sep = ""), "crude P value")
              rownames(uni.res) <- rownames(uni)
              mul <- coefNA(model)[-1, ]
              mul.summ <- paste(round(exp(mul[, 1]), decimal), 
                  " (", round(exp(mul[, 1] - 1.96 * mul[, 2]), 
                    decimal), ",", round(exp(mul[, 1] + 1.96 * 
                    mul[, 2]), decimal), ")", sep = "")
              mul.res <- t(rbind(mul.summ, ifelse(mul[, 4] <= 0.001, 
                  "< 0.001", as.character(round(mul[, 4], decimal + 
                    1)))))
              colnames(mul.res) <- c(paste("adj. OR.(", 100 - 100 * 
                  0.05, "%CI)", sep = ""), "adj. P value")
          }
          res <- cbind(uni.res[rownames(uni.res) %in% rownames(mul.res), 
              ], mul.res)
          rownames(res) <- rownames(mul)
      }
      fix.all <- res
      mdata <- model$model
      fix.all.list <- lapply(1:length(xs), function(x) {
          fix.all[rownames(fix.all) %in% rn.uni[[x]], ]
      })
      varnum.mfac <- which(lapply(fix.all.list, length) > ncol(fix.all))
      lapply(varnum.mfac, function(x) {
          fix.all.list[[x]] <<- rbind(rep(NA, ncol(fix.all)), fix.all.list[[x]])
      })
      fix.all.unlist <- Reduce(rbind, fix.all.list)
      rn.list <- lapply(1:length(xs), function(x) {
          rownames(fix.all)[rownames(fix.all) %in% rn.uni[[x]]]
      })
      varnum.2fac <- which(xs %in% names(model$xlevels)[lapply(model$xlevels, 
          length) == 2])
      lapply(varnum.2fac, function(x) {
          rn.list[[x]] <<- paste(xs[x], ": ", model$xlevels[[xs[x]]][2], 
              " vs ", model$xlevels[[xs[x]]][1], sep = "")
      })
      lapply(varnum.mfac, function(x) {
          rn.list[[x]] <<- c(paste(xs[x], ": ref.=", model$xlevels[[xs[x]]][1], 
              sep = ""), gsub(xs[x], "   ", rn.list[[x]]))
      })
      if (class(fix.all.unlist) == "character") {
          fix.all.unlist <- t(data.frame(fix.all.unlist))
      }
      rownames(fix.all.unlist) <- unlist(rn.list)
      outcome.name <- names(model$model)[1]
      if (gaussianT) {
          first.line <- paste("Linear regression predicting ", 
              outcome.name, sep = "", "- weighted data\n")
          last.lines <- paste("No. of observations = ", length(model$y), 
              "\n", "AIC value = ", round(model$aic, decimal + 
                  2), "\n", "\n", sep = "")
      }
      else {
          first.line <- paste("Logistic regression predicting ", 
              outcome.name, sep = "", "- weighted data\n")
          last.lines <- paste("No. of observations = ", nrow(model$model), 
              "\n", "\n", sep = "")
      }
      results <- list(first.line = first.line, table = fix.all.unlist, 
          last.lines = last.lines)
      class(results) <- c("display", "list")
      return(results)
  }
  <bytecode: 0xdbb4bd8>
  <environment: namespace:jstable>
   --- function search by body ---
  Function svyregress.display in namespace jstable has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 6. Error: Run svyglm.display (@test-regtable.R#29)  -------------------------
  the condition has length > 1
  Backtrace:
   1. testthat::expect_is(svyregress.display(ds, decimal = 3), "display")
   4. jstable::svyregress.display(ds, decimal = 3)
  
  Stratified Independent Sampling design (with replacement)
  dpbc <- survey::svydesign(id=~1, prob=~randprob, strata=~edema, data=subset(pbc,randomized))
  Stratified Independent Sampling design (with replacement)
  dpbc <- survey::svydesign(id=~1, prob=~randprob, strata=~edema, data=subset(pbc,randomized))
  Stratified Independent Sampling design (with replacement)
  dpbc <- survey::svydesign(id=~1, prob=~randprob, strata=~edema, data=subset(pbc,randomized))
  Stratified Independent Sampling design (with replacement)
  dpbc <- survey::svydesign(id=~1, prob=~randprob, strata=~edema, data=subset(pbc,randomized))
  Stratified Independent Sampling design (with replacement)
  dpbc <- survey::svydesign(id=~1, prob=~randprob, strata=~edema, data=subset(pbc,randomized))
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  jstable
   --- call from context --- 
  svycox.display(model)
   --- call from argument --- 
  if (class(fix.all.unlist) == "character") {
      fix.all.unlist <- t(data.frame(fix.all.unlist))
  }
   --- R stacktrace ---
  where 1: svycox.display(model)
  where 2: eval_bare(expr, quo_get_env(quo))
  where 3: quasi_label(enquo(object), label, arg = "object")
  where 4 at testthat/test-regtable.R#47: expect_is(svycox.display(model), "list")
  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-regtable.R#35: test_that("Run svycox.display", {
      library(survival)
      data(pbc)
      pbc$sex = factor(pbc$sex)
      pbc$stage = factor(pbc$stage)
      pbc$randomized <- with(pbc, !is.na(trt) & trt > 0)
      biasmodel <- glm(randomized ~ age * edema, data = pbc, family = binomial)
      pbc$randprob <- fitted(biasmodel)
      if (is.null(pbc$albumin)) 
          pbc$albumin <- pbc$alb
      dpbc <- survey::svydesign(id = ~1, prob = ~randprob, strata = ~edema, 
          data = subset(pbc, randomized))
      model <- survey::svycoxph(Surv(time, status > 0) ~ sex + 
          protime + albumin + stage, design = dpbc)
      expect_is(svycox.display(model), "list")
  })
  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("jstable")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (svycoxph.obj, decimal = 2) 
  {
      model <- svycoxph.obj
      if (!any(class(model) == "svycoxph")) {
          stop("Model not from Survey cox model")
      }
      xf <- attr(model$terms, "term.labels")
      formula.surv <- as.character(model$formula)[2]
      design.model <- model$survey.design
      if (length(xf) == 1) {
          uni.res <- data.frame(summary(model)$coefficients)
          names(uni.res)[ncol(uni.res)] <- "p"
          uni.res2 <- uni.res[, c(1, 3, 4, 5)]
          fix.all = coxExp(uni.res2, dec = decimal)
          colnames(fix.all) <- c("HR(95%CI)", "P value")
          rownames(fix.all) <- names(model$coefficients)
      }
      else {
          unis <- lapply(xf, function(x) {
              uni.res <- data.frame(summary(survey::svycoxph(as.formula(paste(formula.surv, 
                  "~", x, sep = "")), design = design.model))$coefficients)
              names(uni.res)[ncol(uni.res)] <- "p"
              uni.res2 <- uni.res[, c(1, 3, 4, 5)]
              return(uni.res2)
          })
          unis2 <- Reduce(rbind, unis)
          uni.res <- unis2
          mul.res <- data.frame(summary(model)$coefficients)
          uni.res <- uni.res[rownames(uni.res) %in% rownames(mul.res), 
              ]
          colnames(mul.res)[ncol(mul.res)] <- "p"
          fix.all <- cbind(coxExp(uni.res, dec = decimal), coxExp(mul.res[rownames(uni.res), 
              names(uni.res)], dec = decimal))
          colnames(fix.all) <- c("crude HR(95%CI)", "crude P value", 
              "adj. HR(95%CI)", "adj. P value")
          rownames(fix.all) <- rownames(uni.res)
      }
      fix.all.list <- lapply(xf, function(x) {
          fix.all[grepl(x, rownames(fix.all)), ]
      })
      varnum.mfac <- which(lapply(fix.all.list, length) > ncol(fix.all))
      lapply(varnum.mfac, function(x) {
          fix.all.list[[x]] <<- rbind(rep(NA, ncol(fix.all)), fix.all.list[[x]])
      })
      fix.all.unlist <- Reduce(rbind, fix.all.list)
      rn.list <- lapply(xf, function(x) {
          rownames(fix.all)[grepl(x, rownames(fix.all))]
      })
      varnum.2fac <- which(xf %in% names(model$xlevels)[lapply(model$xlevels, 
          length) == 2])
      lapply(varnum.2fac, function(x) {
          rn.list[[x]] <<- paste(xf[x], ": ", model$xlevels[[xf[x]]][2], 
              " vs ", model$xlevels[[xf[x]]][1], sep = "")
      })
      lapply(varnum.mfac, function(x) {
          rn.list[[x]] <<- c(paste(xf[x], ": ref.=", model$xlevels[[xf[x]]][1], 
              sep = ""), gsub(xf[x], "   ", rn.list[[x]]))
      })
      if (class(fix.all.unlist) == "character") {
          fix.all.unlist <- t(data.frame(fix.all.unlist))
      }
      rownames(fix.all.unlist) <- unlist(rn.list)
      pv.colnum <- which(colnames(fix.all.unlist) %in% c("P value", 
          "crude P value", "adj. P value"))
      for (i in pv.colnum) {
          fix.all.unlist[, i] <- ifelse(as.numeric(fix.all.unlist[, 
              i]) < 0.001, "< 0.001", round(as.numeric(fix.all.unlist[, 
              i]), decimal + 1))
      }
      no.obs <- model$n
      no.event <- model$nevent
      aic <- round(stats::AIC(model)[2], decimal)
      metric.mat <- cbind(c(NA, no.obs, no.event, aic), matrix(NA, 
          4, ncol(fix.all) - 1))
      rownames(metric.mat) <- c(NA, "No. of observations", "No. of events", 
          "AIC")
      surv.string <- as.character(attr(model$terms, "variables")[[2]])
      time.var.name <- surv.string[2]
      status.var.name <- surv.string[3]
      intro <- paste("Survey cox model on time ('", time.var.name, 
          "') to event ('", status.var.name, "')", sep = "")
      return(list(table = fix.all.unlist, metric = metric.mat, 
          caption = intro))
  }
  <bytecode: 0xd9788c8>
  <environment: namespace:jstable>
   --- function search by body ---
  Function svycox.display in namespace jstable has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 7. Error: Run svycox.display (@test-regtable.R#47)  -------------------------
  the condition has length > 1
  Backtrace:
   1. testthat::expect_is(svycox.display(model), "list")
   4. jstable::svycox.display(model)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  jstable
   --- call from context --- 
  lmerExp(uni.res, family = family.lmer, dec = dec)
   --- call from argument --- 
  if (class(lmer.coef) == "numeric") {
      lmer.coef = t(data.frame(lmer.coef))
  }
   --- R stacktrace ---
  where 1: lmerExp(uni.res, family = family.lmer, dec = dec)
  where 2: cbind(lmerExp(uni.res, family = family.lmer, dec = dec), lmerExp(fixef, 
      family = family.lmer, dec = dec))
  where 3: lmer.display(lmer(Weight ~ Time + Feed + (1 | Pig) + (1 | Evit), 
      data = dietox))
  where 4: eval_bare(expr, quo_get_env(quo))
  where 5: quasi_label(enquo(object), label, arg = "object")
  where 6 at testthat/test-regtable.R#66: expect_is(lmer.display(lmer(Weight ~ Time + Feed + (1 | Pig) + 
      (1 | Evit), data = dietox)), "list")
  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-regtable.R#64: test_that("Run lmer.display", {
      expect_is(lmer.display(lmer(Reaction ~ Days + (1 | Subject), 
          sleepstudy)), "list")
      expect_is(lmer.display(lmer(Weight ~ Time + Feed + (1 | Pig) + 
          (1 | Evit), data = dietox)), "list")
      dietox$Weight_cat <- as.integer(dietox$Weight > 50)
      expect_is(lmer.display(glmer(Weight_cat ~ Time + Cu + (1 | 
          Pig) + (1 | Evit), data = dietox, family = binomial)), 
          "list")
      expect_is(lmer.display(glmer(Weight_cat ~ Time + (1 | Pig) + 
          (1 | Evit), data = dietox, family = binomial)), "list")
  })
  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("jstable")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (lmer.coef, family = "binomial", dec) 
  {
      if (class(lmer.coef) == "numeric") {
          lmer.coef = t(data.frame(lmer.coef))
      }
      pv = 2 * (1 - pnorm(abs(lmer.coef[, 3])))
      if (family == "binomial") {
          OR = paste(round(exp(lmer.coef[, 1]), dec), " (", round(exp(lmer.coef[, 
              1] - 1.96 * lmer.coef[, 2]), dec), ",", round(exp(lmer.coef[, 
              1] + 1.96 * lmer.coef[, 2]), dec), ")", sep = "")
          return(cbind(OR, pv))
      }
      else if (family %in% c(NULL, "gaussian")) {
          coeff = paste(round(lmer.coef[, 1], dec), " (", round(lmer.coef[, 
              1] - 1.96 * lmer.coef[, 2], dec), ",", round(lmer.coef[, 
              1] + 1.96 * lmer.coef[, 2], dec), ")", sep = "")
          return(cbind(coeff, pv))
      }
      else if (family %in% c("poisson", "quasipoisson")) {
          RR = paste(round(exp(lmer.coef[, 1]), dec), " (", round(exp(lmer.coef[, 
              1] - 1.96 * lmer.coef[, 2]), dec), ",", round(exp(lmer.coef[, 
              1] + 1.96 * lmer.coef[, 2]), dec), ")", sep = "")
          return(cbind(RR, pv))
      }
  }
  <bytecode: 0xdba9078>
  <environment: namespace:jstable>
   --- function search by body ---
  Function lmerExp in namespace jstable has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 8. Error: Run lmer.display (@test-regtable.R#66)  ---------------------------
  the condition has length > 1
  Backtrace:
   1. testthat::expect_is(...)
   4. jstable::lmer.display(...)
   6. jstable:::lmerExp(uni.res, family = family.lmer, dec = dec)
  
  == testthat results  ===========================================================
  [ OK: 44 | SKIPPED: 0 | WARNINGS: 6 | FAILED: 8 ]
  1. Error: LabelepiDisplay (@test-label.R#9) 
  2. Error: LabeljsTable (@test-label.R#18) 
  3. Error: LabeljsCox (@test-label.R#27) 
  4. Error: Run glmshow.display (@test-regtable.R#6) 
  5. Error: Run cox2.display (@test-regtable.R#17) 
  6. Error: Run svyglm.display (@test-regtable.R#29) 
  7. Error: Run svycox.display (@test-regtable.R#47) 
  8. Error: Run lmer.display (@test-regtable.R#66) 
  
  Error: testthat unit tests failed
  Execution halted