An R Introduction to Statistics

Cumulative Frequency Graph

A cumulative frequency graph or ogive of a quantitative variable is a curve graphically showing the cumulative frequency distribution.

Example

In the data set faithful, a point in the cumulative frequency graph of the eruptions variable shows the total number of eruptions whose durations are less than or equal to a given level.

Problem

Find the cumulative frequency graph of the eruption durations in faithful.

Solution

We first find the frequency distribution of the eruption durations as follows. Check the previous tutorial on Frequency Distribution for details.

> duration = faithful$eruptions 
> breaks = seq(1.5, 5.5, by=0.5) 
> duration.cut = cut(duration, breaks, right=FALSE) 
> duration.freq = table(duration.cut)

We then compute its cumulative frequency with cumsum, add a starting zero element, and plot the graph.

> cumfreq0 = c(0, cumsum(duration.freq)) 
> plot(breaks, cumfreq0,            # plot the data 
+   main="Old Faithful Eruptions",  # main title 
+   xlab="Duration minutes",        # xaxis label 
+   ylab="Cumulative eruptions")   # yaxis label 
> lines(breaks, cumfreq0)           # join the points

Answer

The cumulative frequency graph of the eruption durations is:

PIC

Exercise

Find the cumulative frequency graph of the eruption waiting periods in faithful.