Thanks so much! And those links are really useful :) brett
Jeremy Baxter wrote: > > Brett > > Hi > > Searching http://www.Rseek.org will return many similar results. You might > find > the following useful in terms of your question re aligning the bars: > > http://users.fmg.uva.nl/rgrasman/rpages/2005/09/error-bars-in-plots.html > > The discussion on this page also refers to the errbar function in the > Hmisc > package. There are other options, searching Rseek will provide many! > > Basically something along the lines of the following will 'fix' your > graph: > > marks <- sample(4:10, size=50, replace=TRUE) > dim(marks) <- c(10,5) > classavg <- colMeans (marks, na.rm=FALSE, dims = 1) > > thegraph <- barplot(classavg, main="Class Average for Quizzes", > xlab="Quiz", > ylab="Average", names = c("1","2","3","4","5"), ylim=c(0,12), axis.lty=1) > str(thegraph) > max <- apply (marks, 2, max) > min <- apply (marks, 2, min) > arrows(thegraph, min, thegraph, max, code=3, angle=90, length=0.125) > > HTH, > Jeremy > >> Hey Everyone, >> >> I'm pretty new at R and wanted to try and make some graphs with dummy >> data >> before using it to analyze my own. I successfully made a bar graph and >> error bars, but I can't figure out how to align them properly (currently >> they are not centered on the bars and some of them aren't even close). >> Here's the >> >> code that I'm using: >> > marks <- sample(4:10, size=50, replace=TRUE) >> > dim(marks) <- c(10,5) >> > classavg <- colMeans (marks, na.rm=FALSE, dims = 1) >> > barplot(classavg, main="Class Average for Quizzes", xlab="Quiz", >> > ylab="Average", names = c("1","2","3","4","5"), ylim=c(0,12), >> axis.lty=1) >> >> box() >> >> > max <- apply (marks, 2, max) >> > min <- apply (marks, 2, min) >> > arrows(1:5, min, 1:5, max, code=3, angle=90, length=0.125) >> >> The error bars are simply ranges for now (I wanted to do that before I >> tried standard deviation/error). If anyone could help me align them it >> would be much appreciated! >> >> brett > --------------- > Jeremy Baxter, Statistics Department, Rhodes University, South Africa. > Views expressed above, no matter how badly spelt, are my own... I think? > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > > -- View this message in context: http://n4.nabble.com/Bar-Plots-Error-Bars-tp947407p947484.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.