Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

6. Summarized Data Distributions > Making a Frequency Polygon

Making a Frequency Polygon

Problem

You want to make a frequency polygon.

Solution

Use geom_freqpoly() (Figure 6-14):

ggplot(faithful, aes(x=waiting)) + geom_freqpoly()
Left: a frequency polygon; right: with wider bins
Figure 6-14. Left: a frequency polygon; right: with wider bins

Discussion

A frequency polygon appears similar to a kernel density estimate curve, but it shows the same information as a histogram. That is, like a histogram, it shows what is in the data, whereas a kernel density estimate is just that—an estimate—and requires you to pick some value for the bandwidth.

Also like a histogram, you can control the bin width for the frequency polygon (Figure 6-14, right):

ggplot(faithful, aes(x=waiting)) + geom_freqpoly(binwidth=4)

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint