O'Reilly logo

Graphing Data with R by John Jay Hilfiger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Stem-and-Leaf Plots

Basic Stem-and-Leaf Plot

This short chapter might be considered “nostalgia” by some because it describes a type of graph that was important in the paper-and-pencil days of data analysis. You probably will not see many examples of this type of graph in modern presentations, but it is included here because it will help you to understand the histogram a little better, which is the topic of Chapter 7. You might also find it useful in the exploratory phase of your data examination. If you are already knowledgeable about histograms, you can skip this chapter without fear of missing necessary material.

The sbp dataset in the multcomp package  includes the variables sbp—the systolic blood pressure of 69 patients—and the gender of each of those people as well as the age of each. We can look at the distribution of the blood pressures with a stem-and-leaf plot. This type of graph reveals not only the general shape of the data distribution, but the (rounded) value of each data point as well.

The stem-and-leaf plot works by putting all of the values in order, from lowest to highest. Then, it reserves a line for all of the values in a common range and writes the last significant digit of each number on the appropriate line. You can use the stem() command  in base R to create a stem-and-leaf plot of the sbp variable in the sbp dataset.  This type  of display, sometimes called a textual display, appears in the R console, not in a graphic window. We can produce ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required