我想制作一个带有矩阵“b”的频率表,它有100个观测值。 我试图将所有观察结果分成15个等级,因此例如频率表应该包括一些没有观察到的“空类”。
但是,当我使用函数表()时,包含其观察结果不为空的类(或级别)。 (12级)
我如何强迫他们有15个级别?
> b <- matrix(as.matrix(b),ncol=1)
> fivenum(b)
[1] 24.2 24.7 24.9 25.1 25.6
> bcut <- seq(from = 24.2, by =0.1, length.out = 16); bcut
[1] 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3
[13] 25.4 25.5 25.6 25.7
> bgroup <- factor(cut(x = b, breaks = bcut, include.lowest = T))
> levels(bgroup)
[1] "[24.2,24.3]" "(24.3,24.4]" "(24.4,24.5]" "(24.6,24.7]"
[5] "(24.7,24.8]" "(24.8,24.9]" "(24.9,25]" "(25.1,25.2]"
[9] "(25.2,25.3]" "(25.3,25.4]" "(25.4,25.5]" "(25.6,25.7]"