@@ -41,7 +41,7 @@ test_that("num,col,text", {
4141 })
4242})
4343
44- test_that(" function ` cleanup` checks variables" , {
44+ test_that(" function cleanup checks variables" , {
4545 expect_error( desplot(oats35 , yield ~ col + row , num = junk ) )
4646 expect_error( desplot(oats35 , yield ~ col + row , col = junk ) )
4747 expect_error( desplot(oats35 , yield ~ col + row , text = junk ) )
@@ -134,6 +134,30 @@ test_that("subset", {
134134 })
135135})
136136
137+ # # ---------------------------------------------------------------------------
138+
139+ test_that(" If a cell has multiple observations, issue a warning." ,{
140+ # No panel factor
141+ dat0 <- expand.grid(col = 1 : 2 , row = 1 : 2 )
142+ dat0 $ y <- rnorm(nrow(dat0 ))
143+ dat0 <- rbind(dat0 , dat0 [1 ,]) # Create one cell that has 2 observations
144+
145+ # One panel factor
146+ dat1 <- expand.grid(state = c(" S1" ," S2" ), col = 1 : 2 , row = 1 : 2 )
147+ dat1 $ y <- rnorm(nrow(dat1 ))
148+ dat1 <- rbind(dat1 , dat1 [1 ,]) # Create one cell that has 2 observations
149+
150+ # Two panel factors
151+ dat2 <- expand.grid(state = c(" S1" ," S2" ), loc = c(" L1" ," L2" ," L3" ), col = 1 : 2 , row = 1 : 2 )
152+ dat2 $ y <- rnorm(nrow(dat2 ))
153+ dat2 <- rbind(dat2 , dat2 [1 ,]) # Create one cell that has 2 observations
154+
155+ expect_warning( desplot(dat0 , y ~ col * row ) )
156+ expect_warning( desplot(dat1 , y ~ col * row | state ) )
157+ expect_warning( desplot(dat2 , y ~ col * row | state * loc ) )
158+ })
159+
160+
137161# ----------------------------------------------------------------------------
138162
139163
0 commit comments