Dot Plots and Stem Plots

Dot Plots

To demonstrate the construction of dot plots (or dot charts) we will use the data in the example below.

Example: The table below provides data on the approximate number of drug related arrests (in thousands) from 2001 to 2010.

Year2001200220032004200520062007200820092010
Number of Arrests35302931303130293231
Source: www.justice.gov

First we'll need to create a data set.

> arrests = c(35, 30, 29, 31, 30, 31, 30, 29, 32, 31)

To create a dot plot we will use the command dotchart.

> dotchart(arrests)

If we want to add more information to our plot we can include the main and xlab arguments.

> dotchart(arrests, main = "Drug Related Arrests - 2001 to 2010", xlab = "Number of Arrests (in thousands)")

Stem Plots

To demonstrate the construction of stem plots (or stem-and-leaf plots) will use the data in the example below.

Example: The table below provides data on the approximate number of drug related arrests (in thousands) from 2001 to 2010.

Celestial BodyNumber of Successful Probes
Sun17
Mercury3
Venus27
Mars24
Jupiter10
Saturn3
Uranus1
Neptune1
Asteroids11
Comets13
Moon52
Source: wikipedia.org

First we'll need to create a data set.

> probes = c(17, 3, 27, 24, 10, 3, 1, 1, 11, 13, 52)

To create a stem plot we will use the command stem.

> stem(probes)

  The decimal point is 1 digit(s) to the right of the |

  0 | 11330137
  2 | 47
  4 | 2

Notice, though, that the "stems" jump by two.  To force the "stems" to step by one we will include the argument scale = 2.

> stem(probes, scale = 2)

  The decimal point is 1 digit(s) to the right of the |

  0 | 1133
  1 | 0137
  2 | 47
  3 | 
  4 | 
  5 | 2

The value for scale will at times require experimentation, with the end goal of having the "stems" step by one.

No comments:

Post a Comment