Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Error: stat_summary requires the following missing aesthetics: y

$
0
0

I'm trying to create a barplot with confidence interval error bars using ggplot. Essentially, I have a variable, Q1, with 7 answer options, and I want to plot the percent of respondents for each option, as a factor of two groups (One and Two) - the percent of subjects in each group that selected each of the 7 answer option.

I've tried adding y= count, y=prop or y=..prop.. to aes in ggplot, but it neither seem to work. Any suggestions are appreciated.

df5 <- filter(df, Q1!="-99",df$Group=="One"|df$Group=="Two") 

ggplot(data = df5, aes(x = Q1)) + 
 stat_summary(fun.y = mean, geom = "bar") +
 stat_summary(fun.data = mean_cl_boot, geom = "errorbar", fun.args = list(mult = 1)) +
    geom_bar(aes(label= scales::percent(..prop..),
                   y= ..prop..,fill = df5$Group), position = "dodge")

Error: stat_summary requires the following missing aesthetics: y.

I'm essentially trying to get something that looks like this, with the error bars representing confidence intervals.

example of barplot with error bars.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>