diff --git a/R/position-dodge2.r b/R/position-dodge2.r index e511b03721..a4c5fdc8ba 100644 --- a/R/position-dodge2.r +++ b/R/position-dodge2.r @@ -138,7 +138,7 @@ find_x_overlaps <- function(df) { overlaps[1] <- counter <- 1 for (i in seq_asc(2, nrow(df))) { - if (is.na(df$xmin[i]) || is.na(df$xmax[i - 1]) || df$xmin[i] > df$xmax[i - 1]) { + if (is.na(df$xmin[i]) || is.na(df$xmax[i - 1]) || df$xmin[i] >= df$xmax[i - 1]) { counter <- counter + 1 } overlaps[i] <- counter diff --git a/tests/testthat/test-position-dodge2.R b/tests/testthat/test-position-dodge2.R index a48bf7fd86..2ef17a4347 100644 --- a/tests/testthat/test-position-dodge2.R +++ b/tests/testthat/test-position-dodge2.R @@ -110,3 +110,11 @@ test_that("NA values are given their own group", { ) expect_equal(find_x_overlaps(df), seq_len(4)) }) + +test_that("groups are different when two blocks have externall touching point",{ + df1 <- data.frame( + xmin = c(0.5, 1.5), + xmax = c(1.5, 2.5) + ) + expect_equal(find_x_overlaps(df1), seq_len(2)) +})