← Back to R Course | Chapter 10: Data Visualization | Lesson 5 of 7

pie()

In this page:

  1. pie()

pie()

pie(values) draws a pie chart from a vector of values, showing each as a proportional slice of the whole. Pie charts are best used sparingly and only for a small number of categories, since comparing slice angles is harder for viewers than comparing bar heights. labels sets the text shown next to each slice.

Note: For more than a handful of categories, prefer barplot() over pie() -- proportions are much easier to compare as bar heights.

Example: pie()

markup
shares <- c(Product_A = 40, Product_B = 35, Product_C = 25)

print(shares)
cat("pie(shares) would draw a pie chart with these three proportional slices\n")
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.