R-帕累托图分组如直方图 [英] R- pareto chart grouping like histogram
问题描述
我需要在R中创建一个Pareto图表。从qcc库的示例中,我需要在之前进行分组:
让我们假设我的表格是:
缺陷< - data.frame(a = c(8,7,6,4,3,3,0, ,0,1))
如果做直方图,我会自动获得分组
hist(缺陷$ a,breaks = c(-1:8))
但是用pareto图表我不会:
pareto.chart(缺陷$ a ,ylab =错误频率)
有没有办法让分组和图表无需分组它与ddply?
我需要得到相同的结果,但不必手动分组。 code> BB< -ddp (bb $ a,ylab =错误频率)
从文档中可以清楚看到 pareto.chart
函数需要汇总数据。如果你不想使用 ddply()
,你可以使用base table()
函数
$ b $
pareto.chart(表(缺陷$ a),ylab =错误频率)
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")
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")
这篇关于R-帕累托图分组如直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!