Skip to content

Commit 1875bb8

Browse files
committed
Special case for 0 rows and 0 aesthetics.
Fixes #1451
1 parent ed69c54 commit 1875bb8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ggplot2 2.0.0.9000
22

3+
* Eliminate spurious warning if you have a layer with no data and no aesthetics
4+
(#1451).
5+
36
* `position = "nudge"` now works (although it doesn't do anything useful)
47
(#1428).
58

R/layer.r

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ Layer <- ggproto("Layer", NULL,
134134
n <- nrow(data)
135135
if (n == 0) {
136136
# No data, so look at longest evaluated aesthetic
137-
n <- max(vapply(evaled, length, integer(1)))
137+
if (length(evaled) == 0) {
138+
n <- 0
139+
} else {
140+
n <- max(vapply(evaled, length, integer(1)))
141+
}
138142
}
139143
check_aesthetics(evaled, n)
140144

0 commit comments

Comments
 (0)