06.09.2021 Views

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

0 20 40 60 80 100 120<br />

(a)<br />

(b)<br />

Figure 6.11: A basic boxplot (panel a), plus the same plot <strong>with</strong> annotations added to explain what aspect<br />

of the data set each part of the boxplot corresponds to (panel b).<br />

.......................................................................................................<br />

> stem( x = afl.margins, scale = .25 )<br />

> stem( x = afl.margins, width = 20 )<br />

The only <strong>other</strong> thing to note about stem <strong>and</strong> leaf plots is the line in which R tells you where the decimal<br />

point is. If our data set had included only the numbers .11, .15, .23, .35 <strong>and</strong> .59 <strong>and</strong> we’d drawn a stem<br />

<strong>and</strong>leafplotofthesedata,thenR would move the decimal point: the stem values would be 1,2,3,4 <strong>and</strong><br />

5, but R would tell you that the decimal point has moved to the left of the | symbol. If you want to see<br />

this in action, try the following comm<strong>and</strong>:<br />

> stem( x = afl.margins / 1000 )<br />

The stem <strong>and</strong> leaf plot itself will look identical to the original one we drew, except <strong>for</strong> the fact that R<br />

will tell you that the decimal point has moved.<br />

6.5<br />

Boxplots<br />

An<strong>other</strong> alternative to histograms is a boxplot, sometimes called a “box <strong>and</strong> whiskers” plot. Like<br />

histograms, they’re most suited to interval or ratio scale data. The idea behind a boxplot is to provide<br />

a simple visual depiction of the median, the interquartile range, <strong>and</strong> the range of the data. And because<br />

they do so in a fairly compact way, boxplots have become a very popular statistical graphic, especially<br />

during the exploratory stage of data analysis when you’re trying to underst<strong>and</strong> the data yourself. Let’s<br />

- 175 -

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

Saved successfully!

Ooh no, something went wrong!