Introduction to Statistics (MAT/SST 115.03 2008S)

R notes for Activity 8-5: Buckle Up!


This activity requires a bit more work with R than we've done in previous exercises. We start by reading in values.

SeatBeltUsage = read.csv("/home/rebelsky/Stats115/Data/SeatBeltUsage05.csv")

The first step is to separate the table into two parts.

Primary = SeatBeltUsage[SeatBeltUsage$LawType == "Primary", ]
Secondary = SeatBeltUsage[SeatBeltUsage$LawType == "Secondary", ]

You will need to extract the CompliancePercentage column from each in order to compute dot plots, means, and medians.

dotPlot(Primary$CompliancePercentage)
summary(Primary$CompliancePercentage)

It may be helpful to draw each dot plot in a separate window. In R, the way we create a new output window depends on the computer system we're using. On Linux (which we use in class), the command is X11(). On a Mac, the command is quartz(). On Microsoft windows, the command is windows(). Hence, on our Linux boxes, you might create new windows for the two new plots with.

X11()
dotPlot(Primary$CompliancePercentage)
X11()
dotPlot(Secondary$CompliancePercentage)

Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-8 Samuel A. Rebelsky.

This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.