Information Technology Reference
In-Depth Information
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
5
10
15
20
25
speed
Figure 1-3. Scatter plot
1.17 Creating a Bar Chart
Problem
You want to create a bar chart.
Solution
Use the
barplot
function. The first argument is a vector of bar heights:
>
barplot(c(height1, height2, height3))
Discussion
The
barplot
function produces a simple bar chart. It assumes that the heights of your
bars are conveniently stored in a vector. That is not always the case, however. Often,
you have a vector of numeric data and a parallel factor that groups the data, and you
want to produce a bar chart of the group means or the group totals. For example, the
airquality
dataset contains a numeric
Temp
column and a
Month
column. We can create