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.

100 m.<br />

0 2 4<br />

Snow’s cholera map of London<br />

Ox<strong>for</strong>d St #2<br />

Ox<strong>for</strong>d St #1<br />

Gt Marlborough<br />

Crown Chapel<br />

Broad St<br />

So Soho<br />

Dean St<br />

Warwick<br />

Briddle St<br />

Vigo St<br />

Coventry St<br />

Figure 6.1: A stylised redrawing of John Snow’s original cholera map. Each small dot represents the<br />

location of a cholera case, <strong>and</strong> each large circle shows the location of a well. As the plot makes clear,<br />

the cholera outbreak is centred very closely on the Broad St pump. This image uses the data from the<br />

HistData package (Friendly, 2011), <strong>and</strong> was drawn using minor alterations to the comm<strong>and</strong>s provided in<br />

the help files. Note that Snow’s original h<strong>and</strong> drawn map used different symbols <strong>and</strong> labels, but you get<br />

the idea.<br />

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

graph <strong>and</strong> how to draw them, as well as showing the basics of how to customise these plots. I’ll then<br />

talk in more detail about R graphics, discussing some of those complicated <strong>and</strong> boring issues. In a future<br />

version of this book, I intend to finish this chapter off by talking about what makes a good or a bad<br />

graph, but I haven’t yet had the time to write that section.<br />

6.1<br />

An overview of R graphics<br />

Reduced to its simplest <strong>for</strong>m, you can think of an R graphic as being much like a painting. You start<br />

out <strong>with</strong> an empty canvas. Every time you use a graphics function, it paints some new things onto<br />

your canvas. Later on, you can paint more things over the top if you want; but just like painting, you<br />

can’t “undo” your strokes. If you make a mistake, you have to throw away your painting <strong>and</strong> start over.<br />

Fortunately, this is way more easy to do when using R than it is when painting a picture in real life: you<br />

- 158 -

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

Saved successfully!

Ooh no, something went wrong!