# Pie Chart

A pie chart of a qualitative data sample consists of pizza wedges that shows the frequency distribution graphically.

#### Example

In the data set painters, the pie chart of the School variable is a collection of pizza wedges showing the proportion of painters in each school.

#### Problem

Find the pie chart of the painter schools in the data set painters.

#### Solution

We first apply the table function to produce the frequency distribution of School.

> library(MASS)                 # load the MASS package
> school = painters\$School      # the painter schools
> school.freq = table(school)   # apply the table function

Then we apply the pie function to produce its pie chart.

> pie(school.freq)              # apply the pie function

The pie chart of the school variable is:

#### Enhanced Solution

To colorize the pie chart, we select a color palette and set it in the col argument of pie.

> colors = c("red", "yellow", "green", "violet",
+   "orange", "blue", "pink", "cyan")
> pie(school.freq,             # apply the pie function
+   col=colors)                # set the color palette

#### Exercise

Find the pie chart of the composition scores in painters.