R - Pie Charts
R - Pie Charts
R Programming language has numerous libraries to create charts and graphs. A pie-chart
is a representation of values as slices of a circle with different colors. The slices are labeled
and the numbers corresponding to each slice is also represented in the chart.
In R the pie chart is created using the pie() function which takes positive numbers as a
vector input. The additional parameters are used to control labels, color, title etc.
Syntax
The basic syntax for creating a pie-chart using the R is −
radius indicates the radius of the circle of the pie chart.(value between −1 and
+1).
clockwise is a logical value indicating if the slices are drawn clockwise or anti
clockwise.
Example
A very simple pie-chart is created using just the input vector and labels. The below script
will create and save the pie chart in the current R working directory.
Example
The below script will create and save the pie chart in the current R working directory.
piepercent<- round(100*x/sum(x), 1)
Explore our latest online courses and learn new skills at your own pace. Enroll and
become a certified expert to boost your career.
3D Pie Chart
A pie chart with 3 dimensions can be drawn using additional packages. The package
plotrix has a function called pie3D() that is used for this.