10.07.2015 Views

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Univariate data 4121:Read 20 items> stem(x)The decimal point is 1 digit(s) to the right of the |0 | 0002223445681 | 234462 | 383 | 1The stem is written to the left and the leaf to the right of the |. If this isn’t clear, look atthe values in the row with a stem of 1. They are 12, 13, 14, 14, and 16. For many datasets, the data is faithfully recorded. In some cases, the data values are truncated toaccommodate the <strong>for</strong>mat.The stem-and-leaf plot gives us a good understanding of a data set. At a glance we cantell the minimum and maximum values (0 and 31); the shape of the distribution ofnumbers (mostly in the 0 to 10 range); and, if we want to, the “middle” of the distribution(between 5 and 6).In practice, stem-and-leaf plots are usually done by hand as data is being collected.This ris best done in two passes: a first to get the stem and the leaves, and a second to sortthe leaves. We may decide the latter step is not necessary, depending on what we want toknow about the numbers.The stem() function As illustrated, stem-and-leaf plots are done in R with the stem()function. The basic usage is simply stem(x), where x is a data vector. If there are toomany leaves <strong>for</strong> a stem, the extra argument scale= can be set, as in stem(x,scale=2).A back-to-back stem and leaf diagram can be used to show two similarly distributeddata sets. For the second data set, the left side of the stem is used. There is no built-in Rfunction to generate these.2.2.2 Strip chartsAn alternative to a stem-and-leaf plot is a strip chart (also referred to as a dotplot). Thisgraphic plots each value of a data set along a line (or strip). As with a stem-and-leaf plot,we can read off all the data. Unlike the stem-and-leaf plot, however, the strip chart doesnot take up much vertical space on a page and so is a favorite of some authors. Variantsare often found in the media.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!