Running ‘testthat.R’ [37s/50s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(lsasim)
  > 
  > test_check("lsasim")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  lsasim
   --- call from context --- 
  cov_yxw_gen(n_ind, n_z, Phi, n_fac, Lambda)
   --- call from argument --- 
  if (class(Lambda) %in% c("numeric", "integer")) {
      Lambda <- lambda_gen(n_ind, n_fac, Lambda, x_names, f_names)
  } else {
      dimnames(Lambda) <- list(x_names, f_names)
  }
   --- R stacktrace ---
  where 1: cov_yxw_gen(n_ind, n_z, Phi, n_fac, Lambda)
  where 2 at testthat/test.replicateScript.R#8: cov_gen(pr_grp_1 = 0.66, n_fac = 9, n_ind = 4, Lambda = c(0.6, 
      0.9))
  where 3: eval(code, test_env)
  where 4: eval(code, test_env)
  where 5: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 6: doTryCatch(return(expr), name, parentenv, handler)
  where 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 8: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 11: tryCatchList(expr, classes, parentenv, handlers)
  where 12: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 13: test_code(desc, code, env = parent.frame())
  where 14 at testthat/test.replicateScript.R#3: test_that("Function ouput identical to script", {
      vcov_yxw <- readRDS("vcov_yxw.rds")
      vcov_yxz <- readRDS("vcov_yxz.rds")
      vcov_yfz <- readRDS("vcov_xfz.rds")
      set.seed(674634)
      vcov <- cov_gen(pr_grp_1 = 0.66, n_fac = 9, n_ind = 4, Lambda = c(0.6, 
          0.9))
      expect_equivalent(vcov$vcov_yxw, vcov_yxw)
      expect_equivalent(vcov$vcov_yxz, vcov_yxz)
      expect_equivalent(vcov$vcov_yfz, vcov_yfz)
  })
  where 15: eval(code, test_env)
  where 16: eval(code, test_env)
  where 17: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 18: doTryCatch(return(expr), name, parentenv, handler)
  where 19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 20: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 23: tryCatchList(expr, classes, parentenv, handlers)
  where 24: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 25: test_code(NULL, exprs, env)
  where 26: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 27: force(code)
  where 28: doWithOneRestart(return(expr), restart)
  where 29: withOneRestart(expr, restarts[[1L]])
  where 30: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 31: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 32: FUN(X[[i]], ...)
  where 33: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 39: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 40: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 41: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 42: test_check("lsasim")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (n_ind, n_z, Phi, n_fac, Lambda) 
  {
      n_ind_rep <- rep(n_ind, n_fac)
      x_names <- paste0("x", 1:sum(n_ind_rep))
      f_names <- paste0("f", 1:length(n_ind_rep))
      w_names <- paste0("w", 1:n_z)
      rownames(Phi) <- colnames(Phi) <- c("y", f_names, w_names)
      l_start <- cumsum(n_ind_rep) - (n_ind_rep - 1)
      l_end <- l_start + n_ind_rep - 1
      n_yxw <- 1 + sum(n_ind_rep) + n_z
      vcov_yxw <- matrix(NA, nrow = n_yxw, ncol = n_yxw)
      rownames(vcov_yxw) <- colnames(vcov_yxw) <- c("y", x_names, 
          w_names)
      if (class(Lambda) %in% c("numeric", "integer")) {
          Lambda <- lambda_gen(n_ind, n_fac, Lambda, x_names, f_names)
      }
      else {
          dimnames(Lambda) <- list(x_names, f_names)
      }
      Phi_f <- Phi[2:(n_fac + 1), 2:(n_fac + 1)]
      cov_x <- Lambda %*% Phi_f %*% t(Lambda)
      var_xf <- Lambda^2 %*% Phi_f + (1 - Lambda^2)
      indicator_vars <- list()
      for (i in seq(n_ind_rep)) {
          indicator_vars[[i]] <- var_xf[l_start[i]:l_end[i], i]
      }
      diag(cov_x) <- unlist(indicator_vars)
      x_indices <- 2:(length(diag(cov_x)) + 1)
      vcov_yxw[x_indices, x_indices] <- cov_x
      for (i in seq(n_ind_rep)) {
          l_seq <- l_start[i]:l_end[i]
          vcov_yxw[1, l_seq + 1] <- Lambda[l_seq, i] * Phi[1, (i + 
              1)]
          vcov_yxw[l_seq + 1, 1] <- t(vcov_yxw[1, l_seq + 1])
      }
      wcol_yxw <- match(w_names, colnames(vcov_yxw))
      wcol_Phi <- match(w_names, colnames(Phi))
      for (i in seq(n_ind_rep)) {
          l_seq <- l_start[i]:l_end[i]
          vcov_yxw[wcol_yxw, l_seq + 1] <- Lambda[l_seq, i] * Phi[wcol_Phi, 
              (i + 1)]
          vcov_yxw[l_seq + 1, wcol_yxw] <- t(vcov_yxw[wcol_yxw, 
              l_seq + 1])
      }
      vcov_yxw[1, wcol_yxw] <- vcov_yxw[wcol_yxw, 1] <- Phi[1, 
          wcol_Phi]
      diag(vcov_yxw) <- 1
      return(vcov_yxw)
  }
  <bytecode: 0x55813a9a7898>
  <environment: namespace:lsasim>
   --- function search by body ---
  Function cov_yxw_gen in namespace lsasim has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1