Database Reference
In-Depth Information
Table 3.4
Example Functions for Visualizing a Single Variable
Function
Purpose
Scatterplot where x is the index and y is the value;
suitable for low-volume data
plot(
data
)
Barplot with vertical or horizontal bars
barplot(
data
)
Cleveland dot plot [12]
dotchart(
data
)
Histogram
hist(
data
)
plot(density(
data
))
Density plot (a continuous histogram)
stem(
data
)
Stem-and-leaf plot
Add a rug representation (1-d plot) of the data to an
existing plot
rug(
data
)
Dotchart and Barplot
Dotchart and barplot portray continuous values with labels from a discrete
variable. A dotchart can be created in R with the function
dotchart(x,
label=…)
, where
x
is a numeric vector and
label
is a vector of categorical
labels for
x
. A barplot can be created with the
barplot(height)
function, where
height
represents a vector or matrix.
Figure 3.10
shows (a) a dotchart and (b)
a barplot based on the
mtcars
dataset, which includes the fuel consumption and
10 aspects of automobile design and performance of 32 automobiles. This dataset
comes with the standard R distribution.