rgraphpareto-chart

R- pareto chart grouping like histogram


I need to create a Pareto chart in R. From the example of "qcc" library I need to do grouping before:

let's suppose my table is:

defect <- data.frame(a=c(8, 7, 6, 4, 3, 3, 3, 0, 0, 1))

If a do a histogram I get the grouping automatically

hist(defect$a, breaks=c(-1:8))

enter image description here

But with a pareto graph I don't:

pareto.chart(defect$a, ylab = "Error frequency")

enter image description here

Is there a way to get the grouping and the chart without having to group it with ddply? I need to get the same result of the following, but without having to group it manually.

bb<-ddply(defect$a, .(a), count)
pareto.chart(bb$a, ylab = "Error frequency")

enter image description here


Solution

  • From the documentation it seems pretty clear that the pareto.chart function expects summarized data. If you don't want to use ddply() you could use the base table() function

    pareto.chart(table(defect$a), ylab = "Error frequency")