Fix plot coordmap for devel version of ggplot2. Closes #2016

This commit is contained in:
Winston Chang
2018-04-19 11:40:26 -05:00
parent f1e27b6ffb
commit 07b223dcb0
2 changed files with 7 additions and 4 deletions

View File

@@ -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)