From 6e4077e7e437afdc97617697330a3aff17c542c3 Mon Sep 17 00:00:00 2001 From: Sergio Oller Date: Fri, 16 Sep 2022 20:42:44 +0200 Subject: [PATCH] Avoid split data frame if there's only one panel --- R/geom-.r | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/geom-.r b/R/geom-.r index defac7a55a..ea515fcdbc 100644 --- a/R/geom-.r +++ b/R/geom-.r @@ -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 (length(levels(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]]]