Skip to content

Commit 97a5f6a

Browse files
authored
Fix aes(groupS) (#4074)
Fix #4072
1 parent c0dc561 commit 97a5f6a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

R/grouping.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ NO_GROUP <- -1L
1111
add_group <- function(data) {
1212
if (empty(data)) return(data)
1313

14-
if (is.null(data$group)) {
14+
if (is.null(data[["group"]])) {
1515
disc <- vapply(data, is.discrete, logical(1))
1616
disc[names(disc) %in% c("label", "PANEL")] <- FALSE
1717

tests/testthat/test-aes-grouping.r

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ test_that("one group per combination of discrete vars", {
2323
expect_equal(groups(plot), 4)
2424
})
2525

26+
test_that("no error for aes(groupS)", {
27+
df2 <- data_frame(x = df$a, y = df$b, groupS = 1)
28+
g <- add_group(df2)
29+
30+
expect_equal(nrow(g), nrow(df2))
31+
expect_equal(names(g), c("x", "y", "groupS", "group"))
32+
})
33+
2634
test_that("label is not used as a grouping var", {
2735
plot <- ggplot(df, aes(x, x, label = a)) + geom_point()
2836
expect_equal(group(plot), rep(NO_GROUP, 4))

0 commit comments

Comments
 (0)