diff --git a/DESCRIPTION b/DESCRIPTION
index 9780d66..892b5b8 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -36,7 +36,8 @@ Suggests:
survey,
knitr,
rmarkdown,
- testthat
+ testthat,
+ vdiffr
Enhances:
brms,
rstanarm
diff --git a/tests/figs/brmsfit-plots-2/pbfcat.svg b/tests/figs/brmsfit-plots-2/pbfcat.svg
new file mode 100644
index 0000000..5566359
--- /dev/null
+++ b/tests/figs/brmsfit-plots-2/pbfcat.svg
@@ -0,0 +1,50 @@
+
+
diff --git a/tests/figs/brmsfit-plots-2/pbfcont.svg b/tests/figs/brmsfit-plots-2/pbfcont.svg
new file mode 100644
index 0000000..10942b7
--- /dev/null
+++ b/tests/figs/brmsfit-plots-2/pbfcont.svg
@@ -0,0 +1,57 @@
+
+
diff --git a/tests/figs/brmsfit-plots/pcatbfit.svg b/tests/figs/brmsfit-plots/pcatbfit.svg
new file mode 100644
index 0000000..a016705
--- /dev/null
+++ b/tests/figs/brmsfit-plots/pcatbfit.svg
@@ -0,0 +1,50 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3bar.svg b/tests/figs/cat-plot-3-way/p3bar.svg
new file mode 100644
index 0000000..389d2f5
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3bar.svg
@@ -0,0 +1,145 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3bari.svg b/tests/figs/cat-plot-3-way/p3bari.svg
new file mode 100644
index 0000000..0dd0ae9
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3bari.svg
@@ -0,0 +1,145 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3barpp.svg b/tests/figs/cat-plot-3-way/p3barpp.svg
new file mode 100644
index 0000000..0fa0f92
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3barpp.svg
@@ -0,0 +1,372 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3barps.svg b/tests/figs/cat-plot-3-way/p3barps.svg
new file mode 100644
index 0000000..57d7b62
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3barps.svg
@@ -0,0 +1,372 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3line.svg b/tests/figs/cat-plot-3-way/p3line.svg
new file mode 100644
index 0000000..1e5f922
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3line.svg
@@ -0,0 +1,145 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3linei.svg b/tests/figs/cat-plot-3-way/p3linei.svg
new file mode 100644
index 0000000..11db573
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3linei.svg
@@ -0,0 +1,145 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3linelty.svg b/tests/figs/cat-plot-3-way/p3linelty.svg
new file mode 100644
index 0000000..7471472
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3linelty.svg
@@ -0,0 +1,375 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3linepp.svg b/tests/figs/cat-plot-3-way/p3linepp.svg
new file mode 100644
index 0000000..6d97057
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3linepp.svg
@@ -0,0 +1,375 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3lineps.svg b/tests/figs/cat-plot-3-way/p3lineps.svg
new file mode 100644
index 0000000..6282ae0
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3lineps.svg
@@ -0,0 +1,375 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3pt.svg b/tests/figs/cat-plot-3-way/p3pt.svg
new file mode 100644
index 0000000..a5d44e6
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3pt.svg
@@ -0,0 +1,139 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3pti.svg b/tests/figs/cat-plot-3-way/p3pti.svg
new file mode 100644
index 0000000..24e074a
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3pti.svg
@@ -0,0 +1,139 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3ptpp.svg b/tests/figs/cat-plot-3-way/p3ptpp.svg
new file mode 100644
index 0000000..90c33d4
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3ptpp.svg
@@ -0,0 +1,369 @@
+
+
diff --git a/tests/figs/cat-plot-3-way/p3ptps.svg b/tests/figs/cat-plot-3-way/p3ptps.svg
new file mode 100644
index 0000000..c36baa7
--- /dev/null
+++ b/tests/figs/cat-plot-3-way/p3ptps.svg
@@ -0,0 +1,378 @@
+
+
diff --git a/tests/figs/cat-plot-glm/pglmcatoff.svg b/tests/figs/cat-plot-glm/pglmcatoff.svg
new file mode 100644
index 0000000..8920056
--- /dev/null
+++ b/tests/figs/cat-plot-glm/pglmcatoff.svg
@@ -0,0 +1,50 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmbar.svg b/tests/figs/cat-plot-lm/plmbar.svg
new file mode 100644
index 0000000..407500a
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmbar.svg
@@ -0,0 +1,186 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmbari.svg b/tests/figs/cat-plot-lm/plmbari.svg
new file mode 100644
index 0000000..e3a33ad
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmbari.svg
@@ -0,0 +1,186 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmbarpp.svg b/tests/figs/cat-plot-lm/plmbarpp.svg
new file mode 100644
index 0000000..6a0f70c
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmbarpp.svg
@@ -0,0 +1,2186 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmline.svg b/tests/figs/cat-plot-lm/plmline.svg
new file mode 100644
index 0000000..ba30a6d
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmline.svg
@@ -0,0 +1,196 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmlinei.svg b/tests/figs/cat-plot-lm/plmlinei.svg
new file mode 100644
index 0000000..b4c6fda
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmlinei.svg
@@ -0,0 +1,196 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmlinelt.svg b/tests/figs/cat-plot-lm/plmlinelt.svg
new file mode 100644
index 0000000..5451882
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmlinelt.svg
@@ -0,0 +1,2196 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmlinepp.svg b/tests/figs/cat-plot-lm/plmlinepp.svg
new file mode 100644
index 0000000..330a624
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmlinepp.svg
@@ -0,0 +1,2196 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmlineps.svg b/tests/figs/cat-plot-lm/plmlineps.svg
new file mode 100644
index 0000000..80b5d46
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmlineps.svg
@@ -0,0 +1,4301 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmpt.svg b/tests/figs/cat-plot-lm/plmpt.svg
new file mode 100644
index 0000000..8ac2b74
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmpt.svg
@@ -0,0 +1,186 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmpti.svg b/tests/figs/cat-plot-lm/plmpti.svg
new file mode 100644
index 0000000..eb2c5b7
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmpti.svg
@@ -0,0 +1,186 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmptpp.svg b/tests/figs/cat-plot-lm/plmptpp.svg
new file mode 100644
index 0000000..0c6d88d
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmptpp.svg
@@ -0,0 +1,2186 @@
+
+
diff --git a/tests/figs/cat-plot-lm/plmptps.svg b/tests/figs/cat-plot-lm/plmptps.svg
new file mode 100644
index 0000000..06e953a
--- /dev/null
+++ b/tests/figs/cat-plot-lm/plmptps.svg
@@ -0,0 +1,4291 @@
+
+
diff --git a/tests/figs/cat-plot-mermod/plme4cat.svg b/tests/figs/cat-plot-mermod/plme4cat.svg
new file mode 100644
index 0000000..2fbb277
--- /dev/null
+++ b/tests/figs/cat-plot-mermod/plme4cat.svg
@@ -0,0 +1,55 @@
+
+
diff --git a/tests/figs/cat-plot-no-interaction/p0bar.svg b/tests/figs/cat-plot-no-interaction/p0bar.svg
new file mode 100644
index 0000000..a2f5049
--- /dev/null
+++ b/tests/figs/cat-plot-no-interaction/p0bar.svg
@@ -0,0 +1,74 @@
+
+
diff --git a/tests/figs/cat-plot-no-interaction/p0bari.svg b/tests/figs/cat-plot-no-interaction/p0bari.svg
new file mode 100644
index 0000000..eb9d1ad
--- /dev/null
+++ b/tests/figs/cat-plot-no-interaction/p0bari.svg
@@ -0,0 +1,74 @@
+
+
diff --git a/tests/figs/cat-plot-no-interaction/p0barpp.svg b/tests/figs/cat-plot-no-interaction/p0barpp.svg
new file mode 100644
index 0000000..37e3062
--- /dev/null
+++ b/tests/figs/cat-plot-no-interaction/p0barpp.svg
@@ -0,0 +1,2074 @@
+
+
diff --git a/tests/figs/cat-plot-no-interaction/p0pt.svg b/tests/figs/cat-plot-no-interaction/p0pt.svg
new file mode 100644
index 0000000..5636fd6
--- /dev/null
+++ b/tests/figs/cat-plot-no-interaction/p0pt.svg
@@ -0,0 +1,74 @@
+
+
diff --git a/tests/figs/cat-plot-no-interaction/p0pti.svg b/tests/figs/cat-plot-no-interaction/p0pti.svg
new file mode 100644
index 0000000..ae97979
--- /dev/null
+++ b/tests/figs/cat-plot-no-interaction/p0pti.svg
@@ -0,0 +1,74 @@
+
+
diff --git a/tests/figs/cat-plot-no-interaction/p0ptpp.svg b/tests/figs/cat-plot-no-interaction/p0ptpp.svg
new file mode 100644
index 0000000..cbb784b
--- /dev/null
+++ b/tests/figs/cat-plot-no-interaction/p0ptpp.svg
@@ -0,0 +1,2074 @@
+
+
diff --git a/tests/figs/cat-plot-no-interaction/p0ptps.svg b/tests/figs/cat-plot-no-interaction/p0ptps.svg
new file mode 100644
index 0000000..b4672de
--- /dev/null
+++ b/tests/figs/cat-plot-no-interaction/p0ptps.svg
@@ -0,0 +1,2074 @@
+
+
diff --git a/tests/figs/cat-plot-survey/psvycat.svg b/tests/figs/cat-plot-survey/psvycat.svg
new file mode 100644
index 0000000..fc5ff9a
--- /dev/null
+++ b/tests/figs/cat-plot-survey/psvycat.svg
@@ -0,0 +1,50 @@
+
+
diff --git a/tests/figs/deps.txt b/tests/figs/deps.txt
new file mode 100644
index 0000000..0f64e23
--- /dev/null
+++ b/tests/figs/deps.txt
@@ -0,0 +1,3 @@
+- vdiffr-svg-engine: 1.0
+- vdiffr: 0.3.1
+- freetypeharfbuzz: 0.2.5
diff --git a/tests/figs/interact-plot-lm/plm0.svg b/tests/figs/interact-plot-lm/plm0.svg
new file mode 100644
index 0000000..c1107be
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plm0.svg
@@ -0,0 +1,138 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plm1.svg b/tests/figs/interact-plot-lm/plm1.svg
new file mode 100644
index 0000000..4af6aab
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plm1.svg
@@ -0,0 +1,142 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plma.svg b/tests/figs/interact-plot-lm/plma.svg
new file mode 100644
index 0000000..95c7ea2
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plma.svg
@@ -0,0 +1,142 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmlabelsc.svg b/tests/figs/interact-plot-lm/plmlabelsc.svg
new file mode 100644
index 0000000..6c1d276
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmlabelsc.svg
@@ -0,0 +1,142 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmlabelsc2.svg b/tests/figs/interact-plot-lm/plmlabelsc2.svg
new file mode 100644
index 0000000..5b0d5cd
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmlabelsc2.svg
@@ -0,0 +1,142 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmlabelscpred.svg b/tests/figs/interact-plot-lm/plmlabelscpred.svg
new file mode 100644
index 0000000..2bf95b5
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmlabelscpred.svg
@@ -0,0 +1,53 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmlabelscs.svg b/tests/figs/interact-plot-lm/plmlabelscs.svg
new file mode 100644
index 0000000..54972bd
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmlabelscs.svg
@@ -0,0 +1,142 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmlinearchnp.svg b/tests/figs/interact-plot-lm/plmlinearchnp.svg
new file mode 100644
index 0000000..91f9b2b
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmlinearchnp.svg
@@ -0,0 +1,125 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmlinearchp.svg b/tests/figs/interact-plot-lm/plmlinearchp.svg
new file mode 100644
index 0000000..edda7a4
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmlinearchp.svg
@@ -0,0 +1,175 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmm.svg b/tests/figs/interact-plot-lm/plmm.svg
new file mode 100644
index 0000000..eb25c98
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmm.svg
@@ -0,0 +1,138 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmnfchar.svg b/tests/figs/interact-plot-lm/plmnfchar.svg
new file mode 100644
index 0000000..83daee4
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmnfchar.svg
@@ -0,0 +1,59 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmrob.svg b/tests/figs/interact-plot-lm/plmrob.svg
new file mode 100644
index 0000000..c923b64
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmrob.svg
@@ -0,0 +1,142 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmrugb.svg b/tests/figs/interact-plot-lm/plmrugb.svg
new file mode 100644
index 0000000..8cf9f3b
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmrugb.svg
@@ -0,0 +1,191 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmruglb.svg b/tests/figs/interact-plot-lm/plmruglb.svg
new file mode 100644
index 0000000..87052e1
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmruglb.svg
@@ -0,0 +1,241 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmtercs.svg b/tests/figs/interact-plot-lm/plmtercs.svg
new file mode 100644
index 0000000..96460fe
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmtercs.svg
@@ -0,0 +1,134 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmtf.svg b/tests/figs/interact-plot-lm/plmtf.svg
new file mode 100644
index 0000000..1818364
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmtf.svg
@@ -0,0 +1,55 @@
+
+
diff --git a/tests/figs/interact-plot-lm/plmw.svg b/tests/figs/interact-plot-lm/plmw.svg
new file mode 100644
index 0000000..96561fd
--- /dev/null
+++ b/tests/figs/interact-plot-lm/plmw.svg
@@ -0,0 +1,134 @@
+
+
diff --git a/tests/figs/interact-plot-mermod/plme4.svg b/tests/figs/interact-plot-mermod/plme4.svg
new file mode 100644
index 0000000..6c48700
--- /dev/null
+++ b/tests/figs/interact-plot-mermod/plme4.svg
@@ -0,0 +1,53 @@
+
+
diff --git a/tests/figs/interact-plot-mermod/plme4i.svg b/tests/figs/interact-plot-mermod/plme4i.svg
new file mode 100644
index 0000000..446b958
--- /dev/null
+++ b/tests/figs/interact-plot-mermod/plme4i.svg
@@ -0,0 +1,53 @@
+
+
diff --git a/tests/figs/interact-plot-offsets/pglmoff.svg b/tests/figs/interact-plot-offsets/pglmoff.svg
new file mode 100644
index 0000000..6040e61
--- /dev/null
+++ b/tests/figs/interact-plot-offsets/pglmoff.svg
@@ -0,0 +1,59 @@
+
+
diff --git a/tests/figs/interact-plot-offsets/pglmrob.svg b/tests/figs/interact-plot-offsets/pglmrob.svg
new file mode 100644
index 0000000..8b57fd4
--- /dev/null
+++ b/tests/figs/interact-plot-offsets/pglmrob.svg
@@ -0,0 +1,59 @@
+
+
diff --git a/tests/figs/interact-plot-svyglm/psvy1.svg b/tests/figs/interact-plot-svyglm/psvy1.svg
new file mode 100644
index 0000000..a83c07b
--- /dev/null
+++ b/tests/figs/interact-plot-svyglm/psvy1.svg
@@ -0,0 +1,114 @@
+
+
diff --git a/tests/figs/interact-plot-svyglm/psvya.svg b/tests/figs/interact-plot-svyglm/psvya.svg
new file mode 100644
index 0000000..1433d77
--- /dev/null
+++ b/tests/figs/interact-plot-svyglm/psvya.svg
@@ -0,0 +1,114 @@
+
+
diff --git a/tests/figs/stanreg-plots/prsacont.svg b/tests/figs/stanreg-plots/prsacont.svg
new file mode 100644
index 0000000..4b55e15
--- /dev/null
+++ b/tests/figs/stanreg-plots/prsacont.svg
@@ -0,0 +1,67 @@
+
+
diff --git a/tests/testthat.R b/tests/testthat.R
index 8a94edc..609100f 100644
--- a/tests/testthat.R
+++ b/tests/testthat.R
@@ -1,4 +1,5 @@
library(testthat)
+library(vdiffr)
library(interactions)
test_check("interactions")
diff --git a/tests/testthat/test_cat_plot.R b/tests/testthat/test_cat_plot.R
index 76dbe37..6f9958d 100644
--- a/tests/testthat/test_cat_plot.R
+++ b/tests/testthat/test_cat_plot.R
@@ -1,7 +1,6 @@
context("cat_plot lm")
-device <- getOption("device")
-options(device = "pdf")
+library(vdiffr)
if (requireNamespace("lme4", quietly = TRUE)) {
library(lme4, quietly = TRUE)
@@ -16,77 +15,75 @@ diamond <- diamond[samps,]
fit <- lm(price ~ cut * color, data = diamond)
test_that("cat_plot handles simple plot (bar)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut))
- expect_silent(print(p))
+ plmbar <- cat_plot(fit, pred = color, modx = cut)
+ expect_doppelganger("plmbar", plmbar)
})
test_that("cat_plot handles intervals (bar)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, interval = TRUE))
- expect_silent(print(p))
+ plmbari <- cat_plot(fit, pred = color, modx = cut, interval = TRUE)
+ expect_doppelganger("plmbari", plmbari)
})
test_that("cat_plot handles plotted points (bar)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
- plot.points = TRUE))
- expect_silent(print(p))
+ plmbarpp <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
+ plot.points = TRUE)
+ expect_doppelganger("plmbarpp", plmbarpp)
})
test_that("cat_plot handles simple plot (line)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, geom = "line"))
- expect_silent(print(p))
+ plmline <- cat_plot(fit, pred = color, modx = cut, geom = "line")
+ expect_doppelganger("plmline", plmline)
})
test_that("cat_plot handles intervals (line)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
- geom = "line"))
- expect_silent(print(p))
+ plmlinei <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
+ geom = "line")
+ expect_doppelganger("plmlinei", plmlinei)
})
test_that("cat_plot handles plotted points (line)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
- plot.points = TRUE, geom = "line"))
- expect_silent(print(p))
+ plmlinepp <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
+ plot.points = TRUE, geom = "line")
+ expect_doppelganger("plmlinepp", plmlinepp)
})
test_that("cat_plot handles point.shape (line)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
- plot.points = TRUE, geom = "line", point.shape = TRUE))
- expect_silent(print(p))
+ plmlineps <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
+ plot.points = TRUE, geom = "line", point.shape = TRUE)
+ expect_doppelganger("plmlineps", plmlineps)
})
-test_that("cat_plot handles point.shape (line)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
- plot.points = TRUE, geom = "line", point.shape = TRUE,
- vary.lty = TRUE))
- expect_silent(print(p))
+test_that("cat_plot handles linetypes (line)", {
+ plmlinelt <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
+ geom = "line", vary.lty = TRUE, plot.points = TRUE)
+ expect_doppelganger("plmlinelt", plmlinelt)
})
test_that("cat_plot handles simple plot (point)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, geom = "point"))
- expect_silent(print(p))
+ plmpt <- cat_plot(fit, pred = color, modx = cut, geom = "point")
+ expect_doppelganger("plmpt", plmpt)
})
test_that("cat_plot handles intervals (point)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
- geom = "point"))
- expect_silent(print(p))
+ plmpti <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
+ geom = "point")
+ expect_doppelganger("plmpti", plmpti)
})
test_that("cat_plot handles plotted points (point)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
- plot.points = TRUE, geom = "point"))
- expect_silent(print(p))
+ plmptpp <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
+ plot.points = TRUE, geom = "point")
+ expect_doppelganger("plmptpp", plmptpp)
})
test_that("cat_plot handles point.shape (point)", {
- expect_silent(p <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
- plot.points = TRUE, geom = "point",
- point.shape = TRUE))
- expect_silent(print(p))
+ plmptps <- cat_plot(fit, pred = color, modx = cut, interval = TRUE,
+ plot.points = TRUE, geom = "point", point.shape = TRUE)
+ expect_doppelganger("plmptps", plmptps)
})
test_that("cat_plot handles simple plot (boxplot)", {
- expect_error(p <- cat_plot(fit, pred = color, modx = cut, geom = "boxplot"))
+ expect_error(cat_plot(fit, pred = color, modx = cut, geom = "boxplot"))
})
context("cat_plot glm")
@@ -102,8 +99,8 @@ pmod <- glm(counts ~ talent*money, offset = log(exposures), data = poisdat,
family = poisson)
test_that("cat_plot handles offsets", {
- expect_s3_class(p <- cat_plot(pmod, pred = talent), "gg")
- expect_silent(print(p))
+ pglmcatoff <- cat_plot(pmod, pred = talent)
+ expect_doppelganger("pglmcatoff", pglmcatoff)
})
context("cat_plot survey")
@@ -115,16 +112,16 @@ if (requireNamespace("survey")) {
fpc = ~fpc)
regmodel <- svyglm(api00 ~ ell * meals * both + sch.wide, design = dstrat)
test_that("cat_plot handles svyglm", {
- expect_silent(p <- cat_plot(regmodel, pred = both))
- expect_silent(print(p))
+ psvycat <- cat_plot(regmodel, pred = both)
+ expect_doppelganger("psvycat", psvycat)
})
}
context("cat_plot merMod")
test_that("cat_plot handles merMod", {
- expect_silent(p <- cat_plot(mv, pred = mode, modx = Gender, interval = FALSE))
- expect_silent(print(p))
+ plme4cat <- cat_plot(mv, pred = mode, modx = Gender, interval = FALSE)
+ expect_doppelganger("plme4cat", plme4cat)
})
@@ -146,139 +143,126 @@ fit3 <- lm(cty ~ cyl * fwd * auto, data = mpg2)
test_that("cat_plot does 3-way interactions (bar)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "bar"))
- expect_silent(print(p))
+ p3bar <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "bar")
+ expect_doppelganger("p3bar", p3bar)
})
test_that("cat_plot does intervals w/ 3-way interactions (bar)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "bar",
- interval = TRUE))
- expect_silent(print(p))
+ p3bari <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "bar",
+ interval = TRUE)
+ expect_doppelganger("p3bari", p3bari)
})
test_that("cat_plot does plot.points w/ 3-way interactions (bar)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "bar",
- interval = TRUE, plot.points = TRUE))
- expect_silent(print(p))
+ p3barpp <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "bar",
+ interval = TRUE, plot.points = TRUE)
+ expect_doppelganger("p3barpp", p3barpp)
})
test_that("cat_plot does point.shape w/ 3-way interactions (bar)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "bar",
- interval = TRUE, plot.points = TRUE, point.shape = TRUE))
- expect_silent(print(p))
+ p3barps <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "bar",
+ interval = TRUE, plot.points = TRUE, point.shape = TRUE)
+ expect_doppelganger("p3barps", p3barps)
})
test_that("cat_plot does 3-way interactions (line)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line"))
- expect_silent(print(p))
+ p3line <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line")
+ expect_doppelganger("p3line", p3line)
})
test_that("cat_plot does intervals w/ 3-way interactions (line)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line",
- interval = TRUE))
- expect_silent(print(p))
+ p3linei <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line",
+ interval = TRUE)
+ expect_doppelganger("p3linei", p3linei)
})
test_that("cat_plot does plot.points w/ 3-way interactions (line)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line",
- interval = TRUE, plot.points = TRUE))
- expect_silent(print(p))
+ p3linepp <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line",
+ interval = TRUE, plot.points = TRUE)
+ expect_doppelganger("p3linepp", p3linepp)
})
test_that("cat_plot does point.shape w/ 3-way interactions (line)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line",
- interval = TRUE, plot.points = TRUE, point.shape = TRUE))
- expect_silent(print(p))
+ p3lineps <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line",
+ interval = TRUE, plot.points = TRUE, point.shape = TRUE)
+ expect_doppelganger("p3lineps", p3lineps)
})
test_that("cat_plot does vary.lty w/ 3-way interactions (line)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line",
- interval = TRUE, plot.points = TRUE, point.shape = TRUE,
- vary.lty = TRUE))
- expect_silent(print(p))
+ p3linelty <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto,
+ geom = "line", interval = TRUE, plot.points = TRUE,
+ point.shape = TRUE, vary.lty = TRUE)
+ expect_doppelganger("p3linelty", p3linelty)
})
test_that("cat_plot does 3-way interactions (point)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "point"))
- expect_silent(print(p))
+ p3pt <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "point")
+ expect_doppelganger("p3pt", p3pt)
})
test_that("cat_plot does intervals w/ 3-way interactions (point)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "point",
- interval = TRUE))
- expect_silent(print(p))
+ p3pti <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "point",
+ interval = TRUE)
+ expect_doppelganger("p3pti", p3pti)
})
test_that("cat_plot does plot.points w/ 3-way interactions (point)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "point",
- interval = TRUE, plot.points = TRUE))
- expect_silent(print(p))
+ p3ptpp <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "point",
+ interval = TRUE, plot.points = TRUE)
+ expect_doppelganger("p3ptpp", p3ptpp)
})
test_that("cat_plot does point.shape w/ 3-way interactions (point)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "point",
- interval = TRUE, plot.points = TRUE, point.shape = TRUE))
- expect_silent(print(p))
-})
-
-test_that("cat_plot does 3-way interactions (line)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line"))
- expect_silent(print(p))
-})
-
-test_that("cat_plot does plot.points w/ 3-way interactions (line)", {
- expect_silent(p <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "line",
- plot.points = TRUE))
- expect_silent(print(p))
+ p3ptps <- cat_plot(fit3, pred = cyl, modx = fwd, mod2 = auto, geom = "point",
+ interval = TRUE, plot.points = TRUE, point.shape = TRUE)
+ expect_doppelganger("p3ptps", p3ptps)
})
context("cat_plot no interaction")
test_that("cat_plot handles simple plot w/ no mod. (bar)", {
- expect_silent(p <- cat_plot(fit, pred = color))
- expect_silent(print(p))
+ p0bar <- cat_plot(fit, pred = color, geom = "bar")
+ expect_doppelganger("p0bar", p0bar)
})
test_that("cat_plot handles intervals w/ no mod. (bar)", {
- expect_silent(p <- cat_plot(fit, pred = color, interval = TRUE))
- expect_silent(print(p))
+ p0bari <- cat_plot(fit, pred = color, interval = TRUE, geom = "bar")
+ expect_doppelganger("p0bari", p0bari)
})
test_that("cat_plot handles plotted points w/ no mod. (bar)", {
- expect_silent(p <- cat_plot(fit, pred = color, interval = TRUE,
- plot.points = TRUE))
- expect_silent(print(p))
+ p0barpp <- cat_plot(fit, pred = color, interval = TRUE, plot.points = TRUE,
+ geom = "bar")
+ expect_doppelganger("p0barpp", p0barpp)
})
test_that("cat_plot handles simple plot w/ no mod. (point)", {
- expect_silent(p <- cat_plot(fit, pred = color, geom = "point"))
- expect_silent(print(p))
+ p0pt <- cat_plot(fit, pred = color, geom = "point")
+ expect_doppelganger("p0pt", p0pt)
})
test_that("cat_plot handles intervals w/ no mod. (point)", {
- expect_silent(p <- cat_plot(fit, pred = color, interval = TRUE,
- geom = "point"))
- expect_silent(print(p))
+ p0pti <- cat_plot(fit, pred = color, interval = TRUE, geom = "point")
+ expect_doppelganger("p0pti", p0pti)
})
test_that("cat_plot handles plotted points w/ no mod. (point)", {
- expect_silent(p <- cat_plot(fit, pred = color, interval = TRUE,
- plot.points = TRUE, geom = "point"))
- expect_silent(print(p))
+ p0ptpp <- cat_plot(fit, pred = color, interval = TRUE, plot.points = TRUE,
+ geom = "point")
+ expect_doppelganger("p0ptpp", p0ptpp)
})
test_that("cat_plot handles point.shape w/ no mod. (point)", {
- expect_silent(p <- cat_plot(fit, pred = color, interval = TRUE,
- plot.points = TRUE, geom = "point",
- point.shape = TRUE))
- expect_silent(print(p))
+ p0ptps <- cat_plot(fit, pred = color, interval = TRUE, plot.points = TRUE,
+ geom = "point", point.shape = TRUE)
+ expect_doppelganger("p0ptps", p0ptps)
})
if (requireNamespace("brms")) {
context("brmsfit plots")
bfit <- readRDS("brmfit.rds")
test_that("brmsfit objects are supported", {
- expect_silent(print(cat_plot(bfit, pred = "Trt",
- interval = TRUE)))
+ pcatbfit <- cat_plot(bfit, pred = "Trt", interval = TRUE)
+ expect_doppelganger("pcatbfit", pcatbfit)
})
}
diff --git a/tests/testthat/test_interact_plot.R b/tests/testthat/test_interact_plot.R
index 41efbd3..6f1a2c7 100644
--- a/tests/testthat/test_interact_plot.R
+++ b/tests/testthat/test_interact_plot.R
@@ -1,8 +1,5 @@
context("interact_plot lm")
-device <- getOption("device")
-options(device = "pdf")
-
states <- as.data.frame(state.x77)
states$HSGrad <- states$`HS Grad`
states$o70 <- 0
@@ -21,6 +18,8 @@ fitw <- lm(Income ~ HSGrad*Murder*Illiteracy + o70 + Area, data = states,
fitl <- lm(Income ~ HSGrad*o70l, data = states)
fitc <- lm(Income ~ HSGrad*Murder + o70c, data = states)
+library(vdiffr)
+
if (requireNamespace("survey")) {
suppressMessages(library(survey, quietly = TRUE))
data(api)
@@ -30,152 +29,124 @@ if (requireNamespace("survey")) {
}
test_that("interact_plot works for lm", {
- expect_silent(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- centered = "all"))
- expect_silent(print(p))
- expect_warning(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- centered = "HSGrad"))
- expect_silent(print(p))
- expect_silent(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- centered = "Area"))
- expect_silent(print(p))
- expect_silent(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- centered = "none"))
- expect_silent(print(p))
+ plma <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "all")
+ expect_doppelganger("plma", plma)
+ expect_warning(
+ plmm <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "HSGrad")
+ )
+ expect_doppelganger("plmm", plmm)
+ plm1 <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "Area")
+ expect_doppelganger("plm1", plm1)
+ plm0 <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "none")
+ expect_doppelganger("plm0", plm0)
})
test_that("interact_plot: robust standard errors work", {
- expect_silent(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- centered = "all",
- robust = TRUE))
- expect_silent(print(p))
+ plmrob <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "all", robust = TRUE)
+ expect_doppelganger("plmrob", plmrob)
})
test_that("rug plots work", {
- expect_silent(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- centered = "all",
- rug = TRUE))
- expect_silent(print(p))
-
- expect_silent(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- centered = "all",
- rug = TRUE,
- rug.sides = "lb"))
- expect_silent(print(p))
+ plmrugb <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "all", rug = TRUE)
+ expect_doppelganger("plmrugb", plmrugb)
+
+ plmruglb <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "all", rug = TRUE,
+ rug.sides = "lb")
+ expect_doppelganger("plmruglb", plmruglb)
})
test_that("interact_plot works for weighted lm", {
- expect_silent(p <- interact_plot(model = fitw,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- modx.values = c(1, 1.5, 2),
- centered = "all"))
- expect_silent(print(p))
+ plmw <- interact_plot(model = fitw, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, modx.values = c(1, 1.5, 2),
+ centered = "all")
+ expect_doppelganger("plmw", plmw)
})
test_that("interact_plot works for lm w/ logical", {
- expect_silent(p <- interact_plot(model = fitl,
- pred = HSGrad,
- modx = o70l))
- expect_silent(print(p))
+ plmtf <- interact_plot(model = fitl, pred = HSGrad, modx = o70l)
+ expect_doppelganger("plmtf", plmtf)
})
test_that("interact_plot works for lm w/ non-focal character", {
- expect_silent(sim_slopes(model = fitc,
- pred = HSGrad,
- modx = Murder,
- johnson_neyman = FALSE))
- expect_silent(p <- interact_plot(model = fitc,
- pred = HSGrad,
- modx = Murder))
- expect_silent(print(p))
+ plmnfchar <- interact_plot(model = fitc, pred = HSGrad, modx = Murder)
+ expect_doppelganger("plmnfchar", plmnfchar)
})
test_that("interact_plot accepts user-specified values and labels", {
- expect_silent(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- centered = "all",
- modxvals = c(1.5, 2, 2.5),
- modx.labels = c("None","Low","High"),
- mod2vals = c(58, 60, 62),
- mod2.labels = c("Low","Average","High")))
- expect_silent(print(p))
- expect_error(p <- interact_plot(model = fit2,
- pred = o70,
- modx = HSGrad,
- pred.labels = c("Under","Over")))
- expect_silent(p <- interact_plot(model = fit2n,
- pred = o70n,
- modx = HSGrad,
- pred.labels = c("Under","Over")))
- expect_silent(print(p))
+ plmlabelsc <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "all",
+ modxvals = c(1.5, 2, 2.5),
+ modx.labels = c("None","Low","High"),
+ mod2vals = c(58, 60, 62),
+ mod2.labels = c("Low","Average","High"))
+ expect_doppelganger("plmlabelsc", plmlabelsc)
+
+ # Alternate input
+ plmlabelsc2 <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "all",
+ modxvals = c("None" = 1.5, "Low" = 2,
+ "High" = 2.5),
+ mod2vals = c("Low" = 58, "Average" = 60,
+ "High" = 62))
+ expect_doppelganger("plmlabelsc2", plmlabelsc2)
+
+ # Reject logical/factor pred
+ expect_error(interact_plot(model = fit2, pred = o70, modx = HSGrad,
+ pred.labels = c("Under","Over")))
+ plmlabelscpred <- interact_plot(model = fit2n, pred = o70n, modx = HSGrad,
+ pred.labels = c("Under","Over"))
+ expect_doppelganger("plmlabelscpred", plmlabelscpred)
+
+ # Sort properly
+ plmlabelscs <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, centered = "all",
+ modxvals = c(2.5, 2, 1.5),
+ modx.labels = c("High","Low","None"),
+ mod2vals = c(62, 60, 58),
+ mod2.labels = c("High","Average","Low"))
+ expect_doppelganger("plmlabelscs", plmlabelscs)
})
test_that("interact_plot terciles modxval/mod2val works", {
- expect_message(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- mod2 = HSGrad,
- modxvals = "terciles",
- mod2vals = "terciles",
- centered = "none"))
- expect_silent(print(p))
+ expect_message(
+ plmtercs <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ mod2 = HSGrad, modxvals = "terciles",
+ mod2vals = "terciles", centered = "none")
+ )
+ expect_doppelganger("plmtercs", plmtercs)
})
test_that("interact_plot linearity.check works", {
- expect_message(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- modxvals = "terciles",
- linearity.check = TRUE,
- plot.points = TRUE))
- expect_silent(print(p))
- expect_silent(p <- interact_plot(model = fit,
- pred = Murder,
- modx = Illiteracy,
- linearity.check = TRUE))
- expect_silent(print(p))
+ plmlinearchp <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ modxvals = "terciles", linearity.check = TRUE,
+ plot.points = TRUE)
+ expect_doppelganger("plmlinearchp", plmlinearchp)
+ plmlinearchnp <- interact_plot(model = fit, pred = Murder, modx = Illiteracy,
+ modxvals = "terciles", linearity.check = TRUE)
+ expect_doppelganger("plmlinearchnp", plmlinearchnp)
})
context("interact_plot svyglm")
if (requireNamespace("survey")) {
test_that("interact_plot works for svyglm", {
- expect_silent(p <- interact_plot(regmodel, pred = ell, modx = meals,
- mod2 = both,
- centered = "all"))
- expect_silent(print(p))
- expect_warning(p <- interact_plot(regmodel, pred = ell, modx = meals,
- mod2 = both,
- centered = "ell"))
- expect_silent(print(p))
+ psvya <- interact_plot(regmodel, pred = ell, modx = meals, mod2 = both,
+ centered = "all")
+ expect_doppelganger("psvya", psvya)
+ expect_warning(
+ psvy1 <- interact_plot(regmodel, pred = ell, modx = meals, mod2 = both,
+ centered = "ell")
+ )
+ expect_doppelganger("psvy1", psvy1)
})
-
}
context("interact_plot merMod")
@@ -191,12 +162,14 @@ if (requireNamespace("lme4")) {
offset = log(size))
test_that("interact_plot works for lme4", {
- expect_error(p <- interact_plot(mve, pred = mode, modx = Gender))
- expect_silent(p <- interact_plot(mv, pred = mode_numeric, modx = Gender))
- expect_silent(print(p))
- # expect_message(p <- interact_plot(mv, pred = mode_numeric, modx = Gender,
- # interval = TRUE))
- # expect_silent(print(p))
+ expect_error(interact_plot(mve, pred = mode, modx = Gender))
+ plme4 <- interact_plot(mv, pred = mode_numeric, modx = Gender)
+ expect_doppelganger("plme4", plme4)
+ # expect_message(
+ plme4i <- interact_plot(mv, pred = mode_numeric, modx = Gender,
+ interval = TRUE)
+ # )
+ expect_doppelganger("plme4i", plme4i)
})
}
@@ -213,14 +186,17 @@ pmod <- glm(counts ~ talent*money, offset = log(exposures), data = poisdat,
family = poisson)
test_that("interact_plot handles offsets", {
- expect_message(p <- interact_plot(pmod, pred = talent, modx = money))
- expect_silent(print(p))
+ expect_message(
+ pglmoff <- interact_plot(pmod, pred = talent, modx = money)
+ )
+ expect_doppelganger("pglmoff", pglmoff)
})
test_that("interact_plot handles offsets with robust SE", {
- expect_message(p <- interact_plot(pmod, pred = talent, modx = money,
- robust = TRUE))
- expect_silent(print(p))
+ expect_message(
+ pglmrob <- interact_plot(pmod, pred = talent, modx = money, robust = TRUE)
+ )
+ expect_doppelganger("pglmrob", pglmrob)
})
test_that("sim_slopes handles offsets", {
@@ -250,10 +226,11 @@ if (requireNamespace("brms")) {
context("brmsfit plots 2")
bfit <- readRDS("brmfit.rds")
test_that("brmsfit objects are supported", {
- expect_silent(print(cat_plot(bfit, pred = "Trt",
- interval = TRUE)))
- expect_silent(print(interact_plot(bfit, pred = "log_Base4_c", modx = "Trt",
- interval = TRUE)))
+ pbfcat <- cat_plot(bfit, pred = "Trt", interval = TRUE)
+ expect_doppelganger("pbfcat", pbfcat)
+ pbfcont <- interact_plot(bfit, pred = "log_Base4_c", modx = "Trt",
+ interval = TRUE)
+ expect_doppelganger("pbfcont", pbfcont)
})
}
@@ -263,11 +240,9 @@ if (requireNamespace("rstanarm") & requireNamespace("lme4")) {
library(lme4)
data(cbpp)
test_that("stanreg objects are supported", {
- expect_silent(print(interact_plot(rsfit, pred = "size",
- modx = "period", interval = TRUE,
- data = cbpp)))
+ prsacont <- interact_plot(rsfit, pred = "size", modx = "period",
+ interval = TRUE, data = cbpp)
+ expect_doppelganger("prsacont", prsacont)
})
}
-options(device = device)
-dev.off()