Skip to content

Commit d2fd026

Browse files
committed
populate x/y with 0 if absent
1 parent af6f4e8 commit d2fd026

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

R/stat-ydensity.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' @export
55
StatYdensity <- ggproto(
66
"StatYdensity", Stat,
7-
required_aes = c("x", "y"),
7+
required_aes = "x|y",
88
non_missing_aes = "weight",
99

1010
setup_params = function(data, params) {
@@ -23,6 +23,12 @@ StatYdensity <- ggproto(
2323
params
2424
},
2525

26+
setup_data = function(self, data, params) {
27+
var <- flipped_names(flip = params$flipped_aes)$x
28+
data[[var]] <- data[[var]] %||% 0
29+
data
30+
},
31+
2632
# `draw_quantiles` is here for deprecation repair reasons
2733
extra_params = c("na.rm", "orientation", "draw_quantiles"),
2834

0 commit comments

Comments
 (0)