Desktop Survival Guide
by Graham Williams
A http://en.wikipedia.org/wiki/Pie_chartpie chart partitions a circle into proportions related to some data. The R function pie is used to produce a pie chart. A pie chart can be used to again display the proportion of entities spread across some partitioning of the dataset.
Pie charts are a perennial favourite even though common wisdom suggests avoiding them. The human eye is not well suited to differentiating angular variations and a bar chart provides a better alternative. However, many people still enjoy the look of a pie chart
In our example, using the wine dataset, the data is
partitioned on categorical variable Type. The default plot
produced by pie will produce quite a respectable looking
pie chart. We add in to the basic plot the percentage of entities in
each category, including this with the labels of the pie chart. This
helps in communicating the distribution of the data over Type.
load("wine.Rdata") attach(wine) percent <- round(summary(Type) * 100 / nrow(wine)) labels <- sprintf("%s (%d%%)", levels(Type), percent) pie(summary(Type), lab=labels)
Copyright © 2004-2006 Graham.Williams@togaware.com Support further development through the purchase of the PDF version of the book.