gianni lavaredo
2012-Mar-23 20:11 UTC
[R] plot a BARPLOT with sd deviation bar up and down
dear Researchers, i am looking for a function to plot a barplot for each mean value and the related standard deviation, and i can close my week. This is an example of my data set. really Thanks in advance for any help or suggestions Gianni My.mean <- data.frame(Mean=c(0.4108926,0.3949009,0.4520346, 0.4091665,0.4664066,0.3048296,0.4297226,0.4056383, 0.4127453,0.3568891,0.3933964,0.3892999,0.4052982, 0.377359,0.3831106,0.4248397,0.4403693,0.9389882)) My.SD <- data.frame(SD = c(0.3225084,0.3756248,0.3708947, 0.2899242,0.394396,0.4920173,0.2674820,0.3233239,0.2913170, 0.4542726,0.4031899,0.2893581,0.403938,0.3686252,0.4014624, 0.4105261,0.2811270,0.4088456,0.4889143,0.3949252,1.338804)) [[alternative HTML version deleted]]
Hello, I think there's no function in R to print error bars. I once found one in a blog which I'm using. errorbar <- function(x, y, upper, lower=upper, length=0.02, vert=TRUE, ...){ if(!doPlot) return() if(length(x) != length(y) | length(y) !=length(lower) | length(lower) != length(upper)) stop("vectors must be same length") if(vert){ arrows(x, y+upper, x, y-lower, angle=90, code=3, length=length, ...) }else{ arrows(x+upper, y, x-upper, y, angle=90, code=3, length=length, ...) } } Regards!
The discussion here is likely to be helpful: https://stat.ethz.ch/pipermail/r-help/2011-February/269185.html as is: http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4&q=barplot+error+bars&sa=Search+functions%2C+lists%2C+and+more&cof=FORID%3A11&siteurl=www.rseek.org%2F&ref Beyond that, it isn't clear to me that your question is not homework-related. Sarah On Fri, Mar 23, 2012 at 4:11 PM, gianni lavaredo <gianni.lavaredo at gmail.com> wrote:> dear Researchers, > > i am looking for a function to plot a barplot for each mean value and the > related standard deviation, and i can close my week. ?This is an example of > my data set. > > really Thanks in advance for any help or suggestions > > Gianni > > > My.mean <- data.frame(Mean=c(0.4108926,0.3949009,0.4520346, > ?0.4091665,0.4664066,0.3048296,0.4297226,0.4056383, > ?0.4127453,0.3568891,0.3933964,0.3892999,0.4052982, > ?0.377359,0.3831106,0.4248397,0.4403693,0.9389882)) > > My.SD <- data.frame(SD = c(0.3225084,0.3756248,0.3708947, > 0.2899242,0.394396,0.4920173,0.2674820,0.3233239,0.2913170, > 0.4542726,0.4031899,0.2893581,0.403938,0.3686252,0.4014624, > 0.4105261,0.2811270,0.4088456,0.4889143,0.3949252,1.338804)) >-- Sarah Goslee http://www.functionaldiversity.org