From 07b223dcb0d90d7634fca224e3960ceb02772bfc Mon Sep 17 00:00:00 2001 From: Winston Chang Date: Thu, 19 Apr 2018 11:40:26 -0500 Subject: [PATCH] Fix plot coordmap for devel version of ggplot2. Closes #2016 --- DESCRIPTION | 3 ++- R/render-plot.R | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a01249b95..434a45801 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -80,7 +80,8 @@ Imports: later (>= 0.7.1), promises (>= 0.1.0.9001), tools, - crayon + crayon, + rlang Suggests: datasets, Cairo (>= 1.5-5), diff --git a/R/render-plot.R b/R/render-plot.R index c6b1c7e7e..9cce3c9c0 100644 --- a/R/render-plot.R +++ b/R/render-plot.R @@ -555,9 +555,11 @@ find_panel_info_api <- function(b) { # ggplot object. The original uses quoted expressions; convert to # character. mapping <- layers$mapping[[1]] - # lapply'ing as.character results in unexpected behavior for expressions - # like `wt/2`; deparse handles it correctly. - mapping <- lapply(mapping, deparse) + # In ggplot2 <=2.2.1, the mappings are expressions. In later versions, they + # are quosures. `deparse(quo_squash(x))` will handle both cases. + # as.character results in unexpected behavior for expressions like `wt/2`, + # which is why we use deparse. + mapping <- lapply(mapping, function(x) deparse(rlang::quo_squash(x))) # If either x or y is not present, give it a NULL entry. mapping <- mergeVectors(list(x = NULL, y = NULL), mapping)