R Help
Exploratory Data Analysis
Fall 2003
This document describes how to use a number of R commands for plotting one variable and for calcu-
lating one variable summary statistics. Speciﬁcally, it describes how to use R to create
dotplots
,
histograms
,
stemplots
, and
boxplots
, and to compute the
mean
,
median
,
ﬁve-number summary
,
standard deviation
, and
variance
of a variable.
Let’s begin with the same
glucose
data set from last time.
> glucose = c(81, 85, 93, 93, 99, 76, 75, 84, 78, 84, 81, 82, 89,
+
81, 96, 82, 74, 70, 84, 86, 80, 70, 131, 75, 88, 102, 115,
+
89, 82, 79, 106)
Dotplots.
R does not have a built-in dotplot function. I have written a function in R code that works.
The code is on the R Help Web page. Save this ﬁle to your computer and put it in your working directory.
You can source this code using the
File
menu, selecting
Source R code.
..
, and following the directions.
Alternatively,
if the ﬁle dotplot.R is in your working directory
this command will source the code and then
create the dotplot.
> source("dotplot.R")
> dotplot(glucose)
70
80
90
100
110
120
130
●
●
●●
●
● ●●●●
●
●
●
●
●
●
●
●
●● ●●
●
●
●
●
●
●
●
●
●
Histograms.
The
hist
function produces histograms.
> hist(glucose)
Bret Larget
September 15, 2003