@@ -126,7 +126,31 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
126
126
127
127
draw_key = draw_key_polygon ,
128
128
129
- handle_na = function (data , params ) {
129
+ handle_na = function (self , data , params ) {
130
+
131
+ vars <- vapply(
132
+ strsplit(self $ required_aes , " |" , fixed = TRUE ),
133
+ `[[` , i = 1 , character (1 )
134
+ )
135
+ if (params $ flipped_aes || any(data $ flipped_aes ) %|| % FALSE ) {
136
+ vars <- switch_orientation(vars )
137
+ }
138
+ vars <- c(vars , self $ non_missing_aes )
139
+
140
+ missing <- detect_missing(data , vars , finite = FALSE )
141
+ if (! any(missing )) {
142
+ return (data )
143
+ }
144
+ # We're rearranging groups to account for missing values
145
+ data $ group <- vec_identify_runs(data_frame0(missing , data $ group ))
146
+ data <- vec_slice(data , ! missing )
147
+
148
+ if (! params $ na.rm ) {
149
+ cli :: cli_warn(
150
+ " Removed {sum(missing)} row{?s} containing missing values or values \\
151
+ outside the scale range ({.fn {snake_class(self)}})."
152
+ )
153
+ }
130
154
data
131
155
},
132
156
@@ -135,7 +159,6 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
135
159
flipped_aes = FALSE , outline.type = " both" ) {
136
160
data <- check_linewidth(data , snake_class(self ))
137
161
data <- flip_data(data , flipped_aes )
138
- if (na.rm ) data <- data [stats :: complete.cases(data [c(" x" , " ymin" , " ymax" )]), ]
139
162
data <- data [order(data $ group ), ]
140
163
141
164
# Check that aesthetics are constant
0 commit comments