Skip to content

Commit 1517546

Browse files
committed
Copy faster approach from tidyverse#5928
1 parent 6cb6299 commit 1517546

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

R/position-jitterdodge.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ PositionJitterdodge <- ggproto("PositionJitterdodge", Position,
4848
data <- flip_data(data, flipped_aes)
4949
width <- self$jitter.width %||% (resolution(data$x, zero = FALSE, TRUE) * 0.4)
5050

51-
ndodge <- split(data$group, list(data$PANEL, data$x))
52-
ndodge <- max(vapply(ndodge, vec_unique_count, integer(1)))
51+
ndodge <- vec_unique(data[c("group", "PANEL", "x")])
52+
ndodge <- vec_group_id(ndodge[c("PANEL", "x")])
53+
ndodge <- max(tabulate(ndodge, attr(ndodge, "n")))
5354

5455
list(
5556
dodge.width = self$dodge.width %||% 0.75,

tests/testthat/_snaps/position-jitterdodge.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)