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]
hist(vector, breaks=seq(from=min,to=max,by=step) axes=FALSE, main="Title" xlab="Label of X Axis" ) axis(1, seq(from=min,to=max,by=step))
Note that you want to use different sequences for the breaks and the axis. In some models (such as that used in our book), the breaks usually come between values, which means it will be helpful if they have a fractional component. In contrast, you want the tick marks to be in the middle of each bar. For example, if we wanted to deal with values between 0 and 100, grouped into sections of 5, we might use
hist(vector, breaks=seq(from=-2.5,to=102.5,by=5), axes=FALSE, main="Title" xlab="Label of X Axis" ) axis(1, seq(from=0,to=100,by=5))
Histograms provide a visual way to summarize data in cases in which you want to group nearby values. In many ways, they resemble dot plots, but they use broader categories for the dots.
You make histograms with the hist
function>.
It takes as its primary parameter a vector of values. (As is the
case with dotplots, the hist
function will tally
the values for you.)
hist(vector)
If you give R no other information on the histogram, it chooses the breaks for you. Most of the time, you want to choose the breaks yourself.
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.