Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat_summary error when missing ymin/ymax in facet #1445

Closed
tpall opened this issue Dec 22, 2015 · 3 comments
Closed

stat_summary error when missing ymin/ymax in facet #1445

tpall opened this issue Dec 22, 2015 · 3 comments

Comments

@tpall
Copy link

@tpall tpall commented Dec 22, 2015

stat_summary gives error with ggplot2_2.0.0 when missing data for ymin/ymax in at least one facet to calculate errorbars/pointrange.
ggplot2 1.0.1 robustly plotted just points without bars in such facet.

Taavi

Minimal example:

library(ggplot2)
library(dplyr)
mtcars %>% 
   group_by(gear, cyl) %>%
   summarise(hp = mean(hp)) %>%
   ggplot(aes(gear, hp)) + 
   stat_summary(fun.data = mean_se, geom = "pointrange") +
   facet_wrap(~cyl)
Error in FUN(X[[i]], ...) : subscript out of bounds
In addition: Warning message:
Removed 8 rows containing missing values (geom_pointrange). 
@tpall tpall changed the title stat_summary error when single value to calculate errorbar stat_summary error when missing ymin/ymax in facet Jan 4, 2016
@hadley
Copy link
Member

@hadley hadley commented Jan 26, 2016

More minimal reprex:

df <- data.frame(x = c(1, 2, 1), y = c(2, 2, 2), g = c(1, 1, 2), se = c(1, 1, NA))

ggplot(df, aes(x, y)) + 
  stat_summary(fun.data = mean_se, geom = "pointrange") +
  facet_wrap(~g)
@hadley hadley closed this in 5023b79 Jan 26, 2016
@hadley
Copy link
Member

@hadley hadley commented Jan 26, 2016

This eliminates the error, but I'm not sure if this is what you expected. Did pointrange use to display just the points if ymin/ymax were missing?

@tpall
Copy link
Author

@tpall tpall commented Jan 27, 2016

I am happy, my code produces a plot again. Error appeared after upgrade
when I reused my stat_summary line/errorbar plot on a dataset where
errorbars could not be calculated for none of the x value (N=1),
originally, just line was displayed. After upgrade, completely missing
ymin/ymax produced error.

Taavi

On Tue, Jan 26, 2016 at 3:56 PM, Hadley Wickham notifications@github.com
wrote:

This eliminates the error, but I'm not sure if this is what you expected.
Did pointrange use to display just the points if ymin/ymax were missing?


Reply to this email directly or view it on GitHub
#1445 (comment).

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants