R pie chart in R programming

Creating R- pie chart using R programming. 
  1. # Create data for the graph.  
  2. x <-  c(20, 2010,50)  
  3. labels <-  c("Delhi","Haryana","Punjab","Mumbai")  
  4.   
  5. piepercent<- round(100*x/sum(x), 1)  
  6.   
  7. # Give the chart file a name.  
  8. png(file = "city_my.jpg")  
  9.   
  10. # Plot the chart.  
  11. pie(x, labels = piepercent, main = "City pie chart",col = rainbow(length(x)))  
  12. legend("topright", c("Delhi","Haryana","Punjab","Mumbai"), cex = 0.8,  
  13.    fill = rainbow(length(x)))  
  14.   
  15. # Save the file.  
  16. dev.off()