Skip to content

Commit d1043b0

Browse files
committed
mechanism to hide internal variables
1 parent c7abdd7 commit d1043b0

12 files changed

+37
-16
lines changed

R/make-constructor.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ make_constructor <- function(x, ...) {
4444

4545
#' @export
4646
#' @rdname make_constructor
47-
make_constructor.Geom <- function(x, ..., checks = exprs(), env = caller_env()) {
47+
make_constructor.Geom <- function(x, ..., checks = exprs(), omit = character(),
48+
env = caller_env()) {
4849

4950
# Check that we can independently find the geom
5051
geom <- gsub("^geom_", "", snake_class(x))
@@ -61,7 +62,7 @@ make_constructor.Geom <- function(x, ..., checks = exprs(), env = caller_env())
6162

6263
# Fill in values for parameters from draw functions
6364
known_params <-
64-
unique(c(names(args), fixed_fmls_names, "flipped_aes", x$aesthetics()))
65+
unique(c(names(args), fixed_fmls_names, "flipped_aes", x$aesthetics(), omit))
6566
missing_params <- setdiff(x$parameters(), known_params)
6667
if (length(missing_params) > 0) {
6768
draw_args <- ggproto_formals(x$draw_panel)
@@ -128,7 +129,8 @@ make_constructor.Geom <- function(x, ..., checks = exprs(), env = caller_env())
128129

129130
#' @export
130131
#' @rdname make_constructor
131-
make_constructor.Stat <- function(x, ..., checks = exprs(), env = caller_env()) {
132+
make_constructor.Stat <- function(x, ..., checks = exprs(), omit = character(),
133+
env = caller_env()) {
132134
# Check that we can independently find the stat
133135
stat <- gsub("^stat_", "", snake_class(x))
134136
check_subclass(stat, "Stat", env = env)
@@ -143,7 +145,7 @@ make_constructor.Stat <- function(x, ..., checks = exprs(), env = caller_env())
143145
}
144146

145147
known_params <-
146-
unique(c(names(args), fixed_fmls_names, "flipped_aes", x$aesthetics()))
148+
unique(c(names(args), fixed_fmls_names, "flipped_aes", x$aesthetics(), omit))
147149
missing_params <- setdiff(x$parameters(), known_params)
148150

149151
# Fill in missing parameters from the compute methods

R/stat-align.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ StatAlign <- ggproto(
8282
#' @rdname geom_ribbon
8383
stat_align <- make_constructor(
8484
StatAlign, geom = "area",
85-
exclude = c("unique_loc", "adjust")
85+
omit = c("unique_loc", "adjust")
8686
)

R/stat-bin2d.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ StatBin2d <- ggproto(
5757
#' ncount = "count, scaled to maximum of 1.",
5858
#' ndensity = "density, scaled to a maximum of 1."
5959
#' )
60-
stat_bin_2d <- make_constructor(StatBin2d, geom = "tile")
60+
stat_bin_2d <- make_constructor(
61+
StatBin2d, geom = "tile",
62+
omit = c("breaks", "origin")
63+
)
6164

6265
#' @export
6366
#' @rdname geom_bin_2d

R/stat-boxplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@ StatBoxplot <- ggproto("StatBoxplot", Stat,
108108
#' )
109109
stat_boxplot <- make_constructor(
110110
StatBoxplot, geom = "boxplot", position = "dodge2",
111-
orientation = NA
111+
orientation = NA, omit = "width"
112112
)

R/stat-contour.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,17 @@ StatContourFilled <- ggproto(
100100
#'
101101
#'
102102
#' @rdname geom_contour
103-
stat_contour <- make_constructor(StatContour, geom = "contour")
103+
stat_contour <- make_constructor(
104+
StatContour, geom = "contour",
105+
omit = "z.range"
106+
)
104107

105108
#' @rdname geom_contour
106109
#' @export
107-
stat_contour_filled <- make_constructor(StatContourFilled, geom = "contour_filled")
110+
stat_contour_filled <- make_constructor(
111+
StatContourFilled, geom = "contour_filled",
112+
omit = "z.range"
113+
)
108114

109115
#' Calculate the breaks used for contouring
110116
#'

R/stat-count.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ StatCount <- ggproto(
6666
#' @rdname geom_bar
6767
stat_count <- make_constructor(
6868
StatCount, geom = "bar", position = "stack",
69-
orientation = NA
69+
orientation = NA, omit = "width"
7070
)

R/stat-density.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ StatDensity <- ggproto(
7676
#' )
7777
#' @export
7878
#' @rdname geom_density
79-
stat_density <- make_constructor(StatDensity, geom = "area", position = "stack")
79+
stat_density <- make_constructor(
80+
StatDensity, geom = "area", position = "stack",
81+
orientation = NA
82+
)
8083

8184
compute_density <- function(x, w, from, to, bw = "nrd0", adjust = 1,
8285
kernel = "gaussian", n = 512,

R/stat-qq-line.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ StatQqLine <- ggproto(
5656
#' defaults to `c(.25, .75)`.
5757
#' @param fullrange Should the q-q line span the full range of the plot, or just
5858
#' the data
59-
geom_qq_line <- make_constructor(StatQqLine, geom = "path")
59+
geom_qq_line <- make_constructor(StatQqLine, geom = "path", omit = "quantiles")
6060

6161
#' @export
6262
#' @rdname geom_qq

R/stat-quantilemethods.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ StatQuantile <- ggproto(
7373
#' )
7474
#' @export
7575
#' @rdname geom_quantile
76-
stat_quantile <- make_constructor(StatQuantile, geom = "quantile")
76+
stat_quantile <- make_constructor(
77+
StatQuantile, geom = "quantile",
78+
omit = c("xseq", "lambda")
79+
)
7780

7881
quant_pred <- function(quantile, data, method, formula, weight, grid,
7982
method.args = method.args) {

R/stat-smooth.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ StatSmooth <- ggproto(
174174
#' )
175175
#' @export
176176
#' @rdname geom_smooth
177-
stat_smooth <- make_constructor(StatSmooth, geom = "smooth")
177+
stat_smooth <- make_constructor(StatSmooth, geom = "smooth", orientation = NA)
178178

179179
# This function exists to silence an undeclared import warning
180180
gam_method <- function() {

0 commit comments

Comments
 (0)