How to create pie chart and 3D pie chart in R?

Description

To create pie chart and 3D pie chart for the given data using R programming.

Pie Chart:

  • Representation of values as slices
    of a circle with different colours.
  • R Package : plotrix — For 3D
    representation of pie chart
  • R Function : pie()
  • R Function : pie3D()

#Data Visualization in Pie Chart

#Read File
print(getwd())
setwd(“/home/soft13″)
print(getwd())
data<-read.csv(‘input.csv’)
print(data)

#Pie Chart
pie(data$salary,labels=data$name,main=”Pie Chart”,col=rainbow(length(data$salary)))
legend(“topright”,legend=data$name,fill=rainbow(length(data$salary)))

#Pie3D chart
#install.packages(“plotrix”)
library(“plotrix”)
pie3D(data$salary,labels=data$name,main=”Pie Chart”,col=rainbow(length(data$salary)),explode = 0.2)

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit