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]
library(BHH2, lib="/home/rebelsky/Stats115/Packages") dotPlot(vector, axes=FALSE, main="Title" xlab="Label of X Axis" ) axis(1, seq(from=min,to=max,by=step))
Although Workshop Statistics makes a lot of use of dot plots, those kinds of dot plots are not standard in R. Why not? Because there are other ways to represent data, such as histograms, that are often more useful. So why does Workshop Statistics use these simple dot plots? Because they're easy to construct by hand.
Fortunately, R is extensible. Hence, some folks who decided that they
needed simple dot plots added support for them in R. However, you need
to load the BHH2 package, which adds the dotPlot
command.
If you're working at home, on your own computer, you can probably add the package with the following commands:
If you're working at home, on your own computer, you can probably add the package with the following commands:
install.packages("BHH2") library(BHH2)
When you enter the first command, R will probably ask you where to look for R packages. We generally use the Iowa State server, which appears in most lists as “USA (Iowa)”.
Unfortunately, our Linux computers are not configured to allow you to extend R. Hence, you need a somewhat different command.
library(BHH2, lib="/home/rebelsky/Stats115/Packages")
Once you've loaded this library, the
command is available to you.
dotPlot
As in the case of
, you
can call barplot
with just the
data you want plotted. (In this case, you don't have to turn it in
to a table first.)
dotPlot
dotPlot(vector)
Of course, you'll want to add a title to the figure. As in almost
every case, you can use the main
option to add titles.
You can add a label to the X axis with the xlab=...
option.
You may also notice that the tick marks on the X axes are somewhat awkward.
Unfortunately, it's not nearly so easy to fix those. The solution is
to draw the dotplot without any axes and then to add them back in.
You tell R not to draw axes by adding axes=FALSE
to the
command. You tell R what ticks to use when drawing a
horizontal axis with axis(1,vector)
,
where the vector has the tick marks.
dotPlot(Survey$States, axes=FALSE, main="States visited by Intro Stats Students", xlab="Number of States" ) axis(1, seq(from=0,to=50,by=5))
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.