Pie Chart in R

A pie chart is a graph in which a circle is divided into sectors, each representing a proportion of the whole.

pie(x, labels =)

#Pie Chart without Percentages
counts <- c(100, 16,7, 5, 3)
roles <- c(“Software Engineer”, “Team Lead”, “Manager”, “Director”, “Vice President”)
pie( counts, labels = roles, main=”Sample Pie Chart”)

#Pie Chart with Percentages

rolecounts <- c(40, 30,10, 5, 2)
percent <- round(rolecounts/sum(rolecounts)*100)
rolenames <- paste(c(“Software Engineer”, “Team Lead”, “Manager”, “Director”, “Vice President”), percent, “%”, sep=””)
pie(rolecounts, labels=rolenames, col=rainbow(5),main=”Pie Chart with Percentages”)

3-dimensional pie chart can also be created in R

Leave a Reply

%d bloggers like this: