@@ -120,9 +120,10 @@ withr::with_options(
120120 })
121121
122122
123- test_that(" compare_parameters, print_md" , {
123+ test_that(" compare_parameters, print_md-1 " , {
124124 skip_if_not_installed(" lme4" )
125125 skip_if_not_installed(" knitr" )
126+ skip_if_not_installed(" tinytable" )
126127
127128 data(sleepstudy , package = " lme4" )
128129 set.seed(1234 )
@@ -132,24 +133,62 @@ withr::with_options(
132133
133134 cp <- compare_parameters(lm1 , lm2 , select = " {estimate} ({ci})|{p}" , drop = " ^\\ (Intercept" )
134135 out <- print_md(cp , groups = list (
135- Groups = c(" grp (2) " , " grp (3) " ),
136- Interactions = c(" Days * grp (2) " , " Days * grp (3) " ),
137- Controls = " Days "
136+ Groups = c(2 , 3 ),
137+ Interactions = c(4 , 5 ),
138+ Controls = 1
138139 ))
139140 expect_snapshot(print(out ))
141+ })
142+
143+ test_that(" compare_parameters, print_md-2" , {
144+ skip_if_not_installed(" lme4" )
145+ skip_if_not_installed(" knitr" )
146+ skip_if_not_installed(" tinytable" )
147+
148+ data(sleepstudy , package = " lme4" )
149+ set.seed(1234 )
150+ sleepstudy $ grp <- as.factor(sample.int(3 , nrow(sleepstudy ), replace = TRUE ))
151+ lm1 <- lme4 :: lmer(Reaction ~ Days + grp + (1 | Subject ), data = sleepstudy )
152+ lm2 <- lme4 :: lmer(Reaction ~ Days * grp + (1 | Subject ), data = sleepstudy )
153+
154+ cp <- compare_parameters(lm1 , lm2 , select = " {estimate} ({ci})|{p}" , drop = " ^\\ (Intercept" )
155+ out <- display(cp , groups = list (
156+ Groups = c(2 , 3 ),
157+ Interactions = c(4 , 5 ),
158+ Controls = 1
159+ ),
160+ format = " tt"
161+ )
162+ expect_snapshot(print(out ))
163+ })
164+
165+ test_that(" compare_parameters, print_md-3" , {
166+ skip_if_not_installed(" lme4" )
167+ skip_if_not_installed(" knitr" )
168+ skip_if_not_installed(" tinytable" )
169+
170+ data(sleepstudy , package = " lme4" )
171+ set.seed(1234 )
172+ sleepstudy $ grp <- as.factor(sample.int(3 , nrow(sleepstudy ), replace = TRUE ))
173+ lm1 <- lme4 :: lmer(Reaction ~ Days + grp + (1 | Subject ), data = sleepstudy )
174+ lm2 <- lme4 :: lmer(Reaction ~ Days * grp + (1 | Subject ), data = sleepstudy )
140175
141176 cp <- compare_parameters(lm1 , lm2 , select = " {estimate} ({ci})|{p}" , drop = " ^\\ (Intercept" , effects = " all" )
142177 expect_snapshot(print_md(cp ))
178+ expect_snapshot(display(cp , format = " tt" ))
179+ })
180+
181+ test_that(" compare_parameters, print_md-4" , {
182+ skip_if_not_installed(" lme4" )
183+ skip_if_not_installed(" knitr" )
184+ skip_if_not_installed(" tinytable" )
185+
186+ data(sleepstudy , package = " lme4" )
187+ set.seed(1234 )
188+ sleepstudy $ grp <- as.factor(sample.int(3 , nrow(sleepstudy ), replace = TRUE ))
189+ lm1 <- lme4 :: lmer(Reaction ~ Days + grp + (1 | Subject ), data = sleepstudy )
190+ lm2 <- lme4 :: lmer(Reaction ~ Days * grp + (1 | Subject ), data = sleepstudy )
143191
144- # error
145- expect_error(
146- print_md(cp , groups = list (
147- Groups = c(" grp (2)" , " grp (3)" ),
148- Interactions = c(" Days * grp (2)" , " Days * grp (3)" ),
149- Controls = " Days"
150- )),
151- regex = " Cannot combine"
152- )
153192
154193 # with reference level
155194 cp <- compare_parameters(lm1 , lm2 , select = " {estimate} ({ci})|{p}" , drop = " ^\\ (Intercept" , include_reference = TRUE )
@@ -160,6 +199,19 @@ withr::with_options(
160199 ))
161200 expect_snapshot(print(out ))
162201
202+ })
203+
204+ test_that(" compare_parameters, print_md-5" , {
205+ skip_if_not_installed(" lme4" )
206+ skip_if_not_installed(" knitr" )
207+ skip_if_not_installed(" tinytable" )
208+
209+ data(sleepstudy , package = " lme4" )
210+ set.seed(1234 )
211+ sleepstudy $ grp <- as.factor(sample.int(3 , nrow(sleepstudy ), replace = TRUE ))
212+ lm1 <- lme4 :: lmer(Reaction ~ Days + grp + (1 | Subject ), data = sleepstudy )
213+ lm2 <- lme4 :: lmer(Reaction ~ Days * grp + (1 | Subject ), data = sleepstudy )
214+
163215 # with reference level
164216 cp <- compare_parameters(lm1 , lm2 , drop = " ^\\ (Intercept" , include_reference = TRUE )
165217 out <- print_md(cp , groups = list (
@@ -173,8 +225,8 @@ withr::with_options(
173225 cp <- compare_parameters(lm1 , lm2 , select = " {estimate} ({ci})|{p}" , drop = " ^\\ (Intercept" )
174226 expect_error(
175227 print_md(cp , groups = list (
176- Groups = c(" grp (2) " , " grp (3) " ),
177- Interactions = c(" Days * grp (2) " , " Days * grp (3) " ),
228+ Groups = c(2 , 3 ),
229+ Interactions = c(4 , 5 ),
178230 Controls = " XDays"
179231 )),
180232 regex = " Some group indices"
@@ -191,19 +243,19 @@ withr::with_options(
191243 # output identical for both calls
192244 cp1 <- compare_parameters(lm1 , lm2 , select = " {estimate} ({ci})|{p}" , drop = " ^\\ (Intercept" )
193245 out1 <- capture.output(print_md(cp1 , groups = list (
194- Groups = c( " grp (2) " , " grp (3) " ) ,
195- Interactions = c( " Days * grp (2) " , " Days * grp (3) " ) ,
196- Controls = " Days "
246+ Groups = 2 : 3 ,
247+ Interactions = 4 : 5 ,
248+ Controls = 1
197249 )))
198250 cp2 <- compare_parameters(
199251 lm1 ,
200252 lm2 ,
201253 select = " {estimate} ({ci})|{p}" ,
202254 drop = " ^\\ (Intercept" ,
203255 groups = list (
204- Groups = c(" grp (2) " , " grp (3) " ),
205- Interactions = c(" Days * grp (2) " , " Days * grp (3) " ),
206- Controls = " Days "
256+ Groups = c(2 , 3 ),
257+ Interactions = c(4 , 5 ),
258+ Controls = 1
207259 )
208260 )
209261 out2 <- capture.output(print_md(cp2 ))
0 commit comments