Given a minimal dataset where am looking for the occurrence of a certain motif within a dataset of 500 observations. with_motif represents obervations with the specified motif and without_motif are observations without the motif.
with_motif <- 100
without_motif <- 400
dt <- data.frame(with_motif,without_motif)
The following code will plot a bar-chart using ggplot2 library,
bar_plot <- ggplot(melt(dt),aes(variable,value)) + geom_bar() + scale_x_discrete(name="with or without") + theme_bw() + opts( panel.grid.major = theme_blank(),title = "", plot.title=theme_text(size=14))
bar_plot
I would like to compute a standard error at 95% CI and attach a barchart to the plot. ggplot offers geom_errorbar()
but I would be glad to know different ways for deriving the standard errors(deviation) so as to calculate the errorbar limits(CI).
Best Answer
Here's an example from the ggplot2 homepage: https://ggplot2.tidyverse.org/reference/geom_errorbarh.html as others have mentioned in the comments, you have to calculate SE on your own and append this information to the data.frame
As a pointer, SE @ 95% CI usually looks something like this:
Your upper and lower CI bounds will just be df$se +/- the response (as shown in the aes() for geom_errorbar(), above)