Skip to content
Prev 165327 / 398506 Next

error bars

On Fri, 2008-12-19 at 13:06 +0000, Kelly-Gerreyn B.A. wrote:
?par and argument 'las' for basic control. There is a FAQ that explains
how to get more control of the rotating:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f
[ click on the close button in the window title bar? ;-) ]

More seriously, if you are looking for a R function to do it, dev.off()
closes the currently active device.

dev.list() shows the devices open on your system, dev.cur() tells you
which device is currently active and dev.set() switches between opened
devices; since from your question I'm guessing you have more than one
opened at a time.
Provide a vector of plotting characters, e.g. 'pch = 1:6'. 'pch' only
controls the plotting character; 'lwd' controls widths of lines, 'lty'
line types. All accept vectors of 'types' so you can specify exactly
what you need.
?arrows

arrows() is the easiest way to cook this up yourself from standard
graphics calls. Just draw an arrow from value+error to value-error on
the axis that has the error. For example, using dummy data:

dat <- data.frame(A = rnorm(10, mean = 3, sd = 2), 
                  B = rnorm(10, 10, sd = 4),
                  C = rnorm(10, 35, sd = 6))
## something to plot
mns <- colMeans(dat)
## some uncertainty
err <- 2 * sd(dat)
## compute space for means +/- err
ylims <- range(c(mns + err, mns - err))
## plot
plot(mns, ylim = ylims)
## add error bars
arrows(1:3, mns + err, 1:3, mns - err, code = 3, 
       angle = 90, length = 0.1)

There are functions in several packages to simplify this process for
you. Do:

RSiteSearch("error bars", restrict="functions")

in your R session for lots of hits.

These are all fairly basic R fundamentals. Perhaps, if you haven't
already done so, take a look at the manual 'An Introduction to R' that
comes with R or one of the several user contributed documents:

http://cran.r-project.org/other-docs.html

HTH

G