【发布时间】:2020-02-18 04:31:00
【问题描述】:
我正在尝试将 cut() 我的数据 D 分成 3 部分:[0-4]、[5-12]、[13-40](见下图)。但我想知道如何在cut 中准确定义我的breaks 以实现这一目标?
这是我的数据和 R 代码:
D <- read.csv("https://raw.githubusercontent.com/rnorouzian/m/master/t.csv", h = T)
table(cut(D$time, breaks = c(0, 5, 9, 12))) ## what should breaks be?
# (0,5] (5,9] (9,12] # cuts not how I want the 3 pieces .
# 228 37 10
【问题讨论】:
-
在您编写的代码示例中,带有
9的中断不会按照您想要的方式切割,其中没有9。除了那个多余的9,你能具体说明问题是什么吗?
标签: r function dataframe statistics categorical-data