Skip to content

Commit 7ac55dd

Browse files
authored
revert pr for position_dodge2 (#4945)
1 parent c20e142 commit 7ac55dd

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

R/position-dodge2.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ find_x_overlaps <- function(df) {
138138
overlaps[1] <- counter <- 1
139139

140140
for (i in seq_asc(2, nrow(df))) {
141-
if (is.na(df$xmin[i]) || is.na(df$xmax[i - 1]) || df$xmin[i] > df$xmax[i - 1]) {
141+
if (is.na(df$xmin[i]) || is.na(df$xmax[i - 1]) || df$xmin[i] >= df$xmax[i - 1]) {
142142
counter <- counter + 1
143143
}
144144
overlaps[i] <- counter

tests/testthat/test-position-dodge2.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,11 @@ test_that("NA values are given their own group", {
110110
)
111111
expect_equal(find_x_overlaps(df), seq_len(4))
112112
})
113+
114+
test_that("groups are different when two blocks have externall touching point",{
115+
df1 <- data.frame(
116+
xmin = c(0.5, 1.5),
117+
xmax = c(1.5, 2.5)
118+
)
119+
expect_equal(find_x_overlaps(df1), seq_len(2))
120+
})

0 commit comments

Comments
 (0)