# How to create pie chart in base R?

R ProgrammingServer Side ProgrammingProgramming

#### Artificial Intelligence : The Future Of Programming

15 Lectures 54 mins

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### C Programming from scratch- Master C Programming

Best Seller

60 Lectures 8 hours

A pie chart is a circular representation of data which is created for either nominal data or ordinal data. The slices in the pie chart depend on the magnitude of the data values. If we want to create a pie chart in base R then pie function can be used.

For Example, if we have a vector called X then the pie chart for values in X can be created by using the below command −

pie(X)

## Example

Following snippet creates a sample data frame −

x<-sample(1:100,3)
pie(x)

## Output

If you execute the above given snippet, it generates the following Output −

## Example

Following snippet creates a sample data frame −

x<-sample(1:100,3)
pie(x)
y<-c(24,28,80,45,38)
pie(y)

## Output

If you execute all the above given snippets as a single program, it generates the following Output −

Updated on 27-Oct-2021 11:40:52