0

是否已经存在确定数据频率大于某个值的函数/方法?与 Excel 频率分布类似,我想将极值分组到最后一个 bin 中(例如,图像中的 >120)。我一直在手动执行此操作,首先使用 hist 函数,然后对大于给定值的中断计数求和。

柱状图,0, 10, 20, ..., 120, >120

4

1 回答 1

7

这是一个选项:

d <- rlnorm(1000, 3)
d.cut <- cut(d, c(seq(0, 120, 10), Inf))
hist(as.numeric(d.cut), breaks=0:13, xaxt='n', xlab='', 
     col=1, border=0, main='', cex.axis=0.8, las=1)
axis(1, at=0:13, labels=c(seq(0, 120, 10), '>120'), cex.axis=0.8)
box()

在此处输入图像描述

于 2013-06-17T05:52:01.187 回答