How to Create Pareto Chart in R

[This article was first published on Methods – finnstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Pareto Chart in R, A Pareto graph is a type of graph that displays the frequencies of the different categories with the cumulated frequencies of the categories.

How to create a Pareto chart in R

This tutorial describes how to create a Pareto chart in R.

Step 1: Create the Data for Pareto Chart

Let’s create a data frame with the product and its count.

The following dataset shows the total counts for each product,

Extract text from pdf in R and word Detection »

# data frame

df <- data.frame(product=c('A', 'B', 'C', 'D', 'E', 'F'),
count=c(40, 57, 50, 82, 17, 16))

#view data

df
    product count
1        A    40
2        B    57
3        C    50
4        D    82
5        E    17
6        F    16

Step 2: Create the Pareto Chart

For the Pareto chart creation, we can make use of the pareto.chart() function from the qcc package, Let’s load the library first.

Funnel Chart in R-Interactive Funnel Plot »

library(qcc)

#create Pareto chart

pareto.chart(df$count)

Pareto chart analysis for df$count

    Frequency Cum.Freq. Percentage Cum.Percent.
  D  82.00000  82.00000   31.29771     31.29771
  B  57.00000 139.00000   21.75573     53.05344
  C  50.00000 189.00000   19.08397     72.13740
  A  40.00000 229.00000   15.26718     87.40458
  E  17.00000 246.00000    6.48855     93.89313
  F  16.00000 262.00000    6.10687    100.00000

The above table output displays the frequency and cumulative frequency of each product.

In more detail

Frequency of product D: 82 | Cumulative frequency: 82

Frequency of brand B: 57 | Cumulative frequency of A, D: 139

And so on.

Transition plot in R-change in time visualization »

Step 3: Modify the Pareto Chart

We can make aesthetic changes in the Pareto chart.

pareto.chart(df$count,
             main='Pareto Chart',
             col=heat.colors(length(df$count)))
Pareto Chart in R

How to Create a Covariance Matrix in R »

The post How to Create Pareto Chart in R appeared first on finnstats.

To leave a comment for the author, please follow the link and comment on their blog: Methods – finnstats.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)