[R] error bars

Sarah Goslee sarah.goslee at gmail.com
Sat Dec 20 15:15:20 CET 2008


These are rather basic; I'd strongly suggest that you at least
read An Intro to R, and maybe some of the other excellent
beginner materials available. The answers are also
easily available through Google, or RSiteSearch.

> 1) rotating the numbers on axes...something to do with par(str) ??

That's a FAQ:

> 2) how to close a window having opened one e.g. windows(7,7)


> 3) how to manipulate the key (e.g. dots, lines etc) on the legend. Using pch just gives me the same key for all functions on  a plot.
> i.e. legend ("right",   legend=c("Model","Obs"), pch= 16 )...in this case both Model and Obs are filled circles!

If you want more than one kind of symbol, you need to specify
that - in your example you only gave pch 16, so that's all
that is used. legend() doesn't "know" anything about your
plot. You need something like:
legend("right",   legend=c("Model","Obs"), pch=c(1,2), lty=c(3,4))

> 4) how to add error bars (SE or STD) to an xy plot

You can draw it yourself with segments(), but easier is to
use errbar from the Hmisc package

> The last is the most important for me right now. All help much appreciated.


Sarah Goslee

More information about the R-help mailing list