- quite often used for sales and marketing purposes because they are said to be able to manipulate the perception.
- not often used in scientific papers
slices = c(40, 20, 40)name (labels) of the slices - WATCH the length
countries = c("US", "UK", "Other")to add the slice size to the labels
countries = paste(countries, slices)countries = paste(countries, slices)
countries = paste(countries, "%", sep = "")Sytax for pie chart
pie(slices, labels=countries, col=c("red", "blue", "white"), main ="Sales Distribution")
if we need to draw pie chart using existing data set , we can use iris data set as below.
attach(iris)
Values = table(Species) # table for counts
labels = paste(names(Values)) pie(Values, labels =labels, main ="Species Distribution")
Draw to 3D format we need the plotrix library.
library(plotrix)
pie3D(slices, labels=countries, explode = 0.05, col=c("red", "blue", "white"), main ="Sales Distribution")
Pie Charts in R
Reviewed by Pubudu Dewagama
on
6:56:00 PM
Rating:
No comments: