Skip to Main Content
Graphing Data with R
book

Graphing Data with R

by John Jay Hilfiger
October 2015
Beginner to intermediate content levelBeginner to intermediate
250 pages
6h 26m
English
O'Reilly Media, Inc.
Content preview from Graphing Data with R

Chapter 5. Box Plots

The Box Plot

Sometimes, it can be helpful to look at summary information about a group of numbers instead of the numbers themselves. One type of graph that does this by breaking the data into well-defined ranges of numbers is the box plot. We will try this graph on a relatively large dataset, one with which our previous types of graphs do not work very well.

There are some interesting datasets in the nlme package. Get this package and load it by using these commands:

> install.packages("nlme")
> library(nlme)

Next, take a look at the MathAchieve dataset. With more than 7,000 rows, this is much larger than the datasets we have dealt with previously. What problems will this create for us if we want to examine the distribution of MathAch scores? Let’s see what happens with a strip chart of this data.

In the code that produces Figure 5-1, as in many following examples, the mfrow argument is used in par() to make multiple graphs appear on one page. The format is mfrow = c(i,j), where i is the number of rows of graphs and j is the number of columns:

# Figure 5-1
library(nlme)
par(mfrow=c(2,1)) # set up one graph above another: 2 rows/1 col

stripchart(MathAchieve$MathAch, method = "jitter",
  main = "a. Math Ach Scores,
  pch = '19'", xlab = "Scores", pch = "19")

stripchart(MathAchieve$MathAch, method = "jitter",
  main = "b. Math Ach Scores,
  pch = '.'", xlab = "Scores", pch = ".")
Figure 5-1. Strip charts of math achievement scores

These strip charts show the results ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

A Course in Statistics with R

A Course in Statistics with R

Prabhanjan N. Tattar, Suresh Ramaiah, B. G. Manjunath

Publisher Resources

ISBN: 9781491922606Errata Page