Hi Eric, It's not really a ggplot question. If you are plotting means you can calculate the standard error as sd/sqrt(n). Then add and subtract the standard error to create ymax and ymin.
Best, Ista On Sat, Feb 19, 2011 at 9:12 PM, Eric Fail <eric.f...@gmx.com> wrote: > Can't anybody give me a hint on how to solve this? I even bought the > ggplot2-book, so you could also give a page (or a series of pages). > > Thanks, > Eric > > On Thu, Feb 17, 2011 at 10:19 AM, Eric Fail <eric.f...@gmx.com> wrote: >> >> Dear R-list >> >> I'm working with with geom_errorbar; specifically I'm trying to >> reproduce the example Hadley Wickham have on >> http://had.co.nz/ggplot2/geom_errorbar.html (all in the button of the >> page) where he makes an nice plot with errorbars and then draw lines >> between the points. >> >> What confuses me is the 'limits' he defines for the errorbars from the >> se variable. >> >> First he creates a dataset, >> >> df <- data.frame( >> trt = factor(c(1, 1, 2, 2)), >> resp = c(1, 5, 3, 4), >> group = factor(c(1, 2, 1, 2)), >> se = c(0.1, 0.3, 0.3, 0.2) >> ) >> >> # library(ggplot2) >> >> and then he creates some limits from the se variables. >> >> limits <- aes(ymax = resp + se, ymin=resp - se) >> >> [elements omitted] >> >> # and then he creates the plot (I'm interested in). >> >> p <- ggplot(df, aes(colour=group, y=resp, x=trt)) >> p + geom_line(aes(group=group)) + geom_errorbar(limits, width=0.2) >> >> I can (of course) get Hadley's example to run, but I can't do it on my >> data as I don't have a 'se' variable/don't know how to create it. I >> have a group variable, a treatment variable, and a response variable, >> but no se variable. >> >> Could anyone out there explain how I create a 'se' variable in my data? >> >> I'm sure my reasoning is the one that is off, and not ggplot2 (I'm a big >> fan). >> >> Your help is appreciated! >> >> Thanks, >> Eric > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.