Skip to content

Commit

Permalink
Merge pull request #4991 from zeehio/perf-draw-panel
Browse files Browse the repository at this point in the history
Performance: Avoid split.data.frame if there's only one panel
  • Loading branch information
teunbrand authored Jan 5, 2023
2 parents d85eb62 + 7c6d056 commit 853266c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/geom-.r
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ Geom <- ggproto("Geom",
# Trim off extra parameters
params <- params[intersect(names(params), self$parameters())]

lapply(split(data, data$PANEL), function(data) {
if (nlevels(as.factor(data$PANEL)) > 1L) {
data_panels <- split(data, data$PANEL)
} else {
data_panels <- list(data)
}
lapply(data_panels, function(data) {
if (empty(data)) return(zeroGrob())

panel_params <- layout$panel_params[[data$PANEL[1]]]
Expand Down

0 comments on commit 853266c

Please sign in to comment.