使用应用族对不同因子水平进行汇总统计 [英] Summary statistics using apply family for different factor levels
本文介绍了使用应用族对不同因子水平进行汇总统计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到不同因子水平的汇总统计数据.
I am trying to find the summary statistics for different factor levels.
data.frame(apply(final_data[Company=="BPO",c(66:84)],2,summary))
现在我为 company
设置了不同的值 - 我可以为不同的值重复该语句.我知道它可以自动化 - 使用应用系列(ddply
,tapply
,sapply
),但我没有做对.
Now I have different values for company
- i can repeat the statement for different values. I know it can be automated - using apply family (ddply
,tapply
,sapply
), but I am not getting it right.
推荐答案
您可以拆分公司,然后使用您的功能:
You could split on company and then use your function:
spl = split(final_data, final_data$Company)
list.of.summaries = lapply(spl, function(x) data.frame(apply(x[,66:84], 2, summary)))
这篇关于使用应用族对不同因子水平进行汇总统计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文