Skip to main content Accessibility help
×
Hostname: page-component-76fb5796d-x4r87 Total loading time: 0 Render date: 2024-04-29T15:49:39.492Z Has data issue: false hasContentIssue false

5 - Looking at Data – Graphs

from PART I - R AND BASIC STATISTICS

Published online by Cambridge University Press:  22 July 2017

David L. Carlson
Affiliation:
Texas A & M University
Get access

Summary

Tables of counts and statistical summaries are quick and compact ways to begin exploring a new data set, but they are limited. To really visualize data distributions and the relationships among variables, we need charts and graphs. R has extensive graphic capabilities including the standard pie charts, bar charts, histograms, box-and-whisker plots, and scatter plots. Newer methods such as dot plots, kernel density plots, violin plots, and ways of representing three or more variables simultaneously are also available.

R has several graphics systems. One is the base graphics system that is included in R. With this system, graphs and charts are created using functions that write directly to a graphics output device that can be a window on your computer screen or a file. Graphs can be built up using multiple functions that can be stored as R script files, allowing you to regenerate the graph whenever needed (Murrell, 2011). A second graphics system focuses on interactive graphs and 3D graphs using the rgl package. We will use rgl to create an interactive 3-D plot. A third system, lattice, sets up the graph as a grid object (just like data frames or tables are created as objects) and then that object is printed to a graphics device (Sarkar, 2008). Lattice rolls all of the steps you would use with base graphics into a single function call. It is more difficult to learn, but it provides a very easy way to make multiple graphs showing different samples or subgroups of the data set all at once. Finally, a relatively new system that tries to combine the best of base and lattice graphics with a consistent command structure is ggplot2 (Wickham, 2009). We will not try to cover lattice or ggplot2. One of the advantages of R is the large community of people using R and adding new functions. Graphics is a perfect example of this productivity.

There are a number of sources available that describe how to produce graphs and charts that are clear, informative, and easy to interpret. They range from graphs that can be produced simply using a pencil and paper (Tukey, 1977) to graphs that communicate information clearly based on experiments on human perception to see what kinds of depictions are correctly interpreted (Cleveland, 1993, 1994) to graphs that retain an aesthetic quality while communicating effectively (Tufte, 1983, 1990).

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2017

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×