diff --git a/NEWS.md b/NEWS.md index 66e06287a9..58faf9ef28 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # ggplot2 (development version) + +* Fix bug in `labeller()` where parsing was turned off if `.multiline = FALSE` + (@thomasp85, #4084) + * Fix a bug in `qplot()` when supplying `c(NA, NA)` as axis limits (@thomasp85, #4027) diff --git a/R/labeller.r b/R/labeller.r index 0d47f4eb0c..099a2d961d 100644 --- a/R/labeller.r +++ b/R/labeller.r @@ -88,8 +88,13 @@ NULL collapse_labels_lines <- function(labels) { + is_exp <- vapply(labels, function(l) length(l) > 0 && is.expression(l[[1]]), logical(1)) out <- do.call("Map", c(list(paste, sep = ", "), labels)) - list(unname(unlist(out))) + label <- list(unname(unlist(out))) + if (all(is_exp)) { + label <- lapply(label, function(l) list(parse(text = paste0("list(", l, ")")))) + } + label } #' @rdname labellers