Skip to content

Commit 853266c

Browse files
authored
Merge pull request #4991 from zeehio/perf-draw-panel
Performance: Avoid split.data.frame if there's only one panel
2 parents d85eb62 + 7c6d056 commit 853266c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

R/geom-.r

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ Geom <- ggproto("Geom",
7878
# Trim off extra parameters
7979
params <- params[intersect(names(params), self$parameters())]
8080

81-
lapply(split(data, data$PANEL), function(data) {
81+
if (nlevels(as.factor(data$PANEL)) > 1L) {
82+
data_panels <- split(data, data$PANEL)
83+
} else {
84+
data_panels <- list(data)
85+
}
86+
lapply(data_panels, function(data) {
8287
if (empty(data)) return(zeroGrob())
8388

8489
panel_params <- layout$panel_params[[data$PANEL[1]]]

0 commit comments

Comments
 (0)