/ ggplot2 Public

# Regression: NA values not being handled correctly in GeomRibbon#1549

Closed
opened this issue Feb 17, 2016 · 2 comments
Closed

# Regression: NA values not being handled correctly in GeomRibbon #1549

opened this issue Feb 17, 2016 · 2 comments

### MikeWise2718 commented Feb 17, 2016

 There seems to be a missing handle_na function in GeomRibbon. I answered a question with a workaround here: http://stackoverflow.com/questions/35454277/can-you-make-geom-ribbon-leave-a-gap-for-missing-values/35461050#35461050 The text was updated successfully, but these errors were encountered:

### hadley commented Feb 17, 2016

 Can you please include a minimal reproducible example inline?

### MikeWise2718 commented Feb 17, 2016

 Sure. The following program should have a gap at x==4, (where there is an NA in the data). But it does not. However it does if I create a new GeomRibbon identical to the first but with a handle_na default function doing nothing. require(dplyr) require(ggplot2) require(grid) set.seed(1) test <- data.frame(x = rep(1:10, 3), y = abs(rnorm(30)), z = rep(LETTERS[1:3], 10)) %>% arrange(x, z) test[test\$x == 4, "y"] <- NA test\$ymax <- test\$y test\$ymin <- 0 zl <- levels(test\$z) for (i in 2:length(zl)) { zi <- test\$z == zl[i] zi_1 <- test\$z == zl[i - 1] test\$ymin[zi] <- test\$ymax[zi_1] test\$ymax[zi] <- test\$ymin[zi] + test\$ymax[zi] } ggplot(test, aes(x = x, y = y, ymax = ymax, ymin = ymin, fill = z)) + geom_ribbon() + scale_x_continuous(breaks = 1:10)

reopened this Feb 18, 2016
closed this as completed in ``` a760ff6 ``` Feb 18, 2016
bot locked as resolved and limited conversation to collaborators Jun 19, 2018