[R] Error Bars ggplot2
adamjgabbert at gmail.com
Thu Jul 26 19:49:37 CEST 2012
Part of my problem could be that I'm unsure how to nest another variable
withn spd.f. Perhaps if I give a better explanation of my goal things will
make more sense.
My intent is to calculate two sets of confidence intervals to show the
benefits of a DOE approach versus a Non-DOE approach. For example, I want
to calculate the confidence intervals for "f" and "s" in two ways. First
using a DOE approach, by taking the mean of the "f" or "s" values
plus/minus t-value at a 95%ci with 10df multiplied by the standard error
[mean(f-values) +- tval(.95ci,10df)*std.err]. Second using a "bin"
specific approach which only looks at the 6 "f" or "s" values (i.e,
mean(f-values) +- tval(.95ci, 5df)*std.err.mean).
This will leave me with two confidence intervals, that I want to plot side
by side to show that the DOE approach confidence interval will be smaller
for most cases. I have attached a sample plot that shows the plot layout
I'm trying to get.
Your code makes no sense because the variable by which you want to
dodge is the same as the one you're using on the x-axis. Dodging by
subgroups is an application of visualizing nested data, which you
don't have (at least in the state that you posted). For your data,
this would work:
ggplot(data, aes(x = spd, y = r, colour = spd)) +
geom_errorbar(aes(ymin = 3, ymax = 5), width = 0.1) +
I don't understand the point of the second geom_errorbar() call, so
I'm just avoiding it.
In order to dodge (appose groups in factor B side by side within each
level of factor A), you need a third variable whose values are nested
within levels of spd.f.
On Thu, Jul 26, 2012 at 6:03 AM, Adam Gabbert <adamjgabbert at gmail.com>
> I'm attempting to plot error bars side by side rather than stacked on top
> of each other with ggplot2. Here is the sample code I am using:
> #Turn spd into a factor
> #Place data into a data frame
> #Load ggplot2
> #Create plot
> #Display plot
> I have attached a plot that my sample code produces. As you can see the
> error bars are stacked. How can I get them to plot side by side?
More information about the R-help