Introduction to Statistics (MAT/SST 115.03 2008S)
Primary: [Front Door] [Syllabus] [Current Outline] [R] - [Academic Honesty] [Instructions]
Groupings: [Applets] [Assignments] [Data] [Examples] [Handouts] [Labs] [Outlines] [Projects] [Readings] [Solutions]
External Links: [R Front Door] [SamR's Front Door]
As always, we start by reading in some values.
DC = read.csv("/home/rebelsky/Stats115/Data/DigitalCameras.csv") head(DC)
As that summary suggests, the five columns in the table are
Brand
, Model
, Type
, Price
,
Score
. Now, the book asks us to separate them by
type. Lets check what kinds of types there are.
summary(DC$Type)
Well, it looks the the four types are
advanced compact
,
compact
,
subcompact
, and
super-zoom
. Each is probably represented as
a string.
This problem asks us to summarize the data by type of camera. In order to get summaries, we need to break apart the data according to type. Let's start by creating a vector of prices for each of the four kinds of camera. Note that the price is is column 4, so we can use a selector to get the appropriate rows and then just take column 4. From that vector, we compute the six-number summary.
summary(DC[DC$Type=="advanced compact", 4]) summary(DC[DC$Type=="compact", 4]) summary(DC[DC$Type=="subcompact", 4]) summary(DC[DC$Type=="super-zoom", 4])
In addition to those summaries, we might make boxplots.
If we're going to do aligned boxplots, we need a way to
join those boxplots together. Alternately we can look for
a command to draw multiple boxpots, stacked on top of each
other. Fortunately, the split
operation
comes into play here.
boxplot(split(DC$Price,DC$Type), horizontal=T)
Score
column. The particulars of that command are left
as an exercise for the reader.
Primary: [Front Door] [Syllabus] [Current Outline] [R] - [Academic Honesty] [Instructions]
Groupings: [Applets] [Assignments] [Data] [Examples] [Handouts] [Labs] [Outlines] [Projects] [Readings] [Solutions]
External Links: [R Front Door] [SamR's Front Door]
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.