Error in `eval(code, test_env)`: object 'complex_model.asr' not found

test_that("Residual plots work for aov", {
dat.aov <- aov(Petal.Length ~ Petal.Width, data = iris)
vdiffr::expect_doppelganger(title = "Resplot for aov without shapiro", p1)
test_that("resplt is deprecated and produces a warning", {
expect_warning(p1 <- resplt(dat.aov), "resplt has been deprecated in version 1\\.0\\.1 and will be removed in a future version\\.\\nPlease use resplot\\(\\) instead\\.")
vdiffr::expect_doppelganger(title = "Resplot for aov", p1)
test_that("resplot produces an error for invalid data types", {
"model\\.obj must be a linear \\(mixed\\) model object\\. Currently supported model types are: aov, lm, lme, lmerMod, lmerModLmerTest, asreml, mmer, mmes, art")
test_that("Old mod.obj argument produces a warning", {
expect_warning(p <- resplot(model.obj = dat.aov, mod.obj = dat.aov),
"Argument `mod\\.obj` has been deprecated and will be removed in a future version\\. Please use `model\\.obj` instead\\.")
vdiffr::expect_doppelganger(title = "Resplot after warning", p)
test_that("Residual plots work for asreml", {
load(test_path("data", "asreml_model.Rdata"), envir = .GlobalEnv)
p1_single <- resplot(model.asr, shapiro = FALSE, call = TRUE)
"Removed 1 row containing non-finite outside the scale range"),
"Removed 1 row containing missing values or values outside the scale range")
vdiffr::expect_doppelganger(title = "Resplot for asreml single", p1_single)
vdiffr::expect_doppelganger(title = "Resplot for asreml pt 1", p1_multi[[1]])
vdiffr::expect_doppelganger(title = "Resplot for asreml pt 2", p1_multi[[2]])
vdiffr::expect_doppelganger(title = "Resplot for asreml pt 3", p1_multi[[3]])
test_that("Residual plots work for lme4", {
dat.lme4 <- lme4::lmer(Reaction ~ Days + (Days | Subject), lme4::sleepstudy)
vdiffr::expect_doppelganger(title = "Resplot for lme4", p1)
test_that("Residual plots work for nlme", {
dat.nlme <- nlme::nlme(height ~ SSasymp(age, Asym, R0, lrc),
vdiffr::expect_doppelganger(title = "Resplot for nlme", p1)
test_that("Residual plots work for sommer", {
vdiffr::expect_doppelganger(title = "Resplot for sommer mmer", p1)
vdiffr::expect_doppelganger(title = "Resplot for sommer mmes", p2)
test_that("Residual plots display call for aov and lm", {
p2 <- resplot(dat.aov, call = TRUE, call.size = 7)
vdiffr::expect_doppelganger(title = "Resplot with call", p1)
vdiffr::expect_doppelganger(title = "Resplot with smaller call", p2)
test_that("Residual plots work for ARTool models", {
model.art <- ARTool::art(medmolarity ~ name + (1|rep), data = dat.art)
vdiffr::expect_doppelganger(title = "ARTool resplot", p1)
vdiffr::expect_doppelganger(title = "ARTool resplot with call", p2)
test_that("Shapiro-Wilk test produces a warning with large numbers of observations.", {
dat_large.aov <- aov(y ~ x, data = large_dat)
dat_med.aov <- aov(y ~ x, data = med_dat)
expect_warning(p1 <- resplot(dat_large.aov, shapiro = TRUE),
"Shapiro-Wilk test p-values are unreliable for more than 5000 observations and has not been performed")
expect_warning(p2 <- resplot(dat_med.aov, shapiro = TRUE),
"Shapiro-Wilk test p-values are unreliable for large numbers of observations")
vdiffr::expect_doppelganger(title = "Medium data shapiro", p2)
vdiffr::expect_doppelganger(title = "Large data shapiro", p1)
test_that("onepage is ignored for single plots", {
test_that("onepage produces plots with up to 6 on a page", {
p2 <- suppressWarnings(resplot(complex_model.asr, onepage = TRUE))
p3 <- resplot(model_dsum, onepage = TRUE)
test_that("onepage_col produces plots with up to 6 on a page", {
p1 <- suppressWarnings(resplot(complex_model.asr, onepage = TRUE, onepage_cols = 3))
p2 <- suppressWarnings(resplot(complex_model.asr, onepage = TRUE, onepage_cols = 2))