You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should it be possible to "stack" text when calculating the labels and the y axis with stat_summary()? I'm getting an error using either position = "stack" or position = position_stack().
library(ggplot2)
# Using stat_summary for aggregation
ggplot(mtcars, aes(x=factor(cyl), y=mpg, fill=factor(am))) +
stat_summary_bin(fun.y=sum, geom="bar", position="stack")+
stat_summary(aes(label= stat(y)), fun.y=sum, geom="text",
position= position_stack(vjust=.5))
#> Error in if (any(negative)) {: missing value where TRUE/FALSE needed
Things work as I expect when doing the calculation outside of ggplot2.
Not all geometries have a ymax and/or ymin (although most of the ones that are usually stacked do, like geom_bar(), which is why this isn't usually a problem). Changing this to something more like:
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/
lockbot
locked and limited conversation to collaborators
Jan 13, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Should it be possible to "stack" text when calculating the labels and the y axis with
stat_summary()
? I'm getting an error using eitherposition = "stack"
orposition = position_stack()
.Things work as I expect when doing the calculation outside of ggplot2.
Created on 2018-06-21 by the reprex package (v0.2.0).
The text was updated successfully, but these errors were encountered: