The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Kickstarting R - Plotting data - error bars

Illustrating variability

If you are interested in R, you are likely to be interested in statistics, and if you are interested in statistics, you must have some appreciation of variability. One way to illustrate this quantity is with error bars. R has a function named arrows that can simplify this task. arrows requires at least four arguments, the x/y start and end points of each arrow (if each argument is a vector, an arrow will be drawn for each value in the vector). Note that the points will be specified in user units, that is, the units that are actually illustrated on the graph. Start with the start points. These are usually separated from the points marking the values by a small amount. I use the current height of a lower case "m". In order to get bars going up and down, there will have to be two sets of starting points. Similarly, two sets of end points will be needed, calculated by adding and subtracting the value of the standard errors for each of the data points - see plot.dstat().

First, the function checks that its argument is there, and is an object of class "dstat". Now have a look at the arguments to arrows. In addition to the first four arguments specifying the start and end points of the arrows, the length argument specifies the length of the arms in (blush) inches and the angle argument specifies the angle of the arms from the stem.

R has inherited a lot of things from S. Some of them aren't the greatest, like the default units of inches and points. Well, nobody's perfect.

Notice that the function will do its best to work out missing arguments from the data. If error bars are requested, get.dstat.ylim() is called to work out the maximum range of the entire dstat object.

Notice the offset= option in plot.dstat. This allows you to ask for additional points and error bars produced by add.pointline() to be moved side to side so that they don't overlap.

Your idea of a great point/line plot may be somewhat different. By now you should have an idea of the tools that can be used to get that plot.

For more information, see An Introduction to R: High-level plotting commands.

Back to Table of Contents

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.