11test_that(" check_group_variation-1" , {
2- skip_if_not_installed(" lme4" )
3- set.seed(11 )
2+
43 group <- rep(LETTERS [1 : 3 ], each = 3 )
54 variable1 <- rep(letters [1 : 3 ], each = 3 )
5+ variable1b <- rep(letters [1 : 2 ], times = c(6 , 3 ))
66 variable2 <- rep(letters [1 : 3 ], times = 3 )
77 variable3 <- letters [1 : 9 ]
88 variable4 <- c(letters [1 : 5 ], letters [1 : 4 ])
99
10- d <- data.frame (group , variable1 , variable2 , variable3 , variable4 )
10+ d <- data.frame (group , variable1 , variable1b , variable2 , variable3 , variable4 )
1111 out <- check_group_variation(d , by = " group" )
1212
13- out2 <- c(
14- variable1 = lme4 :: isNested(variable1 , group ),
15- variable2 = lme4 :: isNested(variable2 , group ),
16- variable3 = lme4 :: isNested(variable3 , group ),
17- variable4 = lme4 :: isNested(variable4 , group )
18- )
1913 expect_equal(
2014 out ,
2115 data.frame (
22- group = c(" group" , " group" , " group" , " group" ),
23- variable = c(" variable1" , " variable2" , " variable3" , " variable4" ),
24- type = c(" between (nested) " , " within" , " both ( nested) " , " both" )
16+ group = c(" group" , " group" , " group" , " group" , " group " ),
17+ variable = c(" variable1" , " variable1b " , " variable2" , " variable3" , " variable4" ),
18+ type = c(" between" , " between " , " within" , " nested" , " both" )
2519 ),
2620 ignore_attr = TRUE
2721 )
28- expect_equal(
29- endsWith(out $ type , " (nested)" ),
30- out2 ,
31- ignore_attr = TRUE
32- )
22+
3323
3424 set.seed(111 )
3525 dat <- data.frame (
@@ -59,7 +49,7 @@ test_that("check_group_variation-1", {
5949 data.frame (
6050 group = c(" id" , " id" , " id" , " id" , " id" , " id" ),
6151 variable = c(" between_num" , " within_num" , " both_num" , " between_fac" , " within_fac" , " both_fac" ),
62- type = c(" between" , " within" , " both" , " between (nested) " , " within" , " both" )
52+ type = c(" between" , " within" , " both" , " between" , " within" , " both" )
6353 ),
6454 ignore_attr = TRUE
6555 )
@@ -161,7 +151,7 @@ test_that("check_group_variation, multiple by", {
161151 data.frame (
162152 group = c(" schoolid" , " schoolid" , " schoolid" , " schoolid" , " childid" , " childid" , " childid" , " childid" ),
163153 variable = c(" lowinc" , " female" , " year" , " math" , " lowinc" , " female" , " year" , " math" ),
164- type = c(" between (nested) " , " both" , " within" , " both" , " between" , " between" , " within" , " both" )
154+ type = c(" between" , " both" , " within" , " both" , " between" , " between" , " within" , " both" )
165155 ),
166156 ignore_attr = TRUE
167157 )
@@ -179,7 +169,7 @@ test_that("check_group_variation, multiple by", {
179169 " schoolid" , " lowinc" , " female" , " year" , " math"
180170 ),
181171 type = c(
182- " both ( nested) " , " between (nested) " , " both" , " within" , " both" ,
172+ " nested" , " between" , " both" , " within" , " both" ,
183173 " between" , " between" , " between" , " within" , " both"
184174 )
185175 ),
@@ -239,10 +229,10 @@ test_that("check_group_variation, numeric_as_factor", {
239229 )
240230 expect_identical(
241231 out1 $ type ,
242- c(" between (nested) " , " both" , " within" , " both" , " between" , " between" , " within" , " both" )
232+ c(" between" , " both" , " within" , " both" , " between" , " between" , " within" , " both" )
243233 )
244234 expect_identical(
245235 out2 $ type ,
246- c(" between (nested) " , " both" , " within" , " both ( nested) " , " between" , " between" , " within" , " both" )
236+ c(" between" , " both" , " within" , " nested" , " between" , " between" , " within" , " both" )
247237 )
248238})
0 commit comments