From 81f8020a158a0471679785c13983cedb658d5355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 7 Aug 2018 19:06:10 +0200 Subject: [PATCH] Force arguments that are used in closures --- R/save.r | 5 ++++- R/scale-manual.r | 2 ++ R/scale-size.r | 2 ++ R/stat-summary-bin.R | 6 ++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/R/save.r b/R/save.r index 864ed8b559..fdddc7eeac 100644 --- a/R/save.r +++ b/R/save.r @@ -118,7 +118,10 @@ plot_dim <- function(dim = c(NA, NA), scale = 1, units = c("in", "cm", "mm"), dim } -plot_dev <- function(device, filename, dpi = 300) { +plot_dev <- function(device, filename = NULL, dpi = 300) { + force(filename) + force(dpi) + if (is.function(device)) return(device) diff --git a/R/scale-manual.r b/R/scale-manual.r index 35a4d191c7..651a3d379e 100644 --- a/R/scale-manual.r +++ b/R/scale-manual.r @@ -102,6 +102,8 @@ scale_discrete_manual <- function(aesthetics, ..., values) { manual_scale <- function(aesthetic, values, ...) { + force(values) + pal <- function(n) { if (n > length(values)) { stop("Insufficient values in manual scale. ", n, " needed but only ", diff --git a/R/scale-size.r b/R/scale-size.r index 240f9f70e8..fafc562e88 100644 --- a/R/scale-size.r +++ b/R/scale-size.r @@ -68,6 +68,8 @@ scale_size_discrete <- function(...) { #' @export #' @usage NULL scale_size_ordinal <- function(..., range = c(2, 6)) { + force(range) + discrete_scale( "size", "size_d", diff --git a/R/stat-summary-bin.R b/R/stat-summary-bin.R index 21301bd0c1..201f16d9f6 100644 --- a/R/stat-summary-bin.R +++ b/R/stat-summary-bin.R @@ -65,6 +65,12 @@ StatSummaryBin <- ggproto("StatSummaryBin", Stat, ) make_summary_fun <- function(fun.data, fun.y, fun.ymax, fun.ymin, fun.args) { + force(fun.data) + force(fun.y) + force(fun.ymax) + force(fun.ymin) + force(fun.args) + if (!is.null(fun.data)) { # Function that takes complete data frame as input fun.data <- match.fun(fun.data)