R- pareto chart grouping like histogram

六眼飞鱼酱① 提交于 2020-01-03 05:07:16

问题


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))

But with a pareto graph I don't:

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

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")


回答1:


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")


来源:https://stackoverflow.com/questions/27554817/r-pareto-chart-grouping-like-histogram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!