Running ‘testthat.R’ [12s/18s]
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: 0x562eae88aa18>
  <environment: namespace:jstable>
   --- function search by body ---
  Function glmshow.display in namespace jstable has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1