我是 R 新手。我想从原始数据(小数)生成频率表,例如:
x
V1
1 10.10
2 46.65
3 53.60
4 38.50
5 45.95
6 12.25
7 59.60
8 23.30
9 11.05
10 58.35
11 40.20
12 11.05
13 10.45
14 26.45
15 13.25
16 21.15
17 35.00
18 29.05
19 25.40
20 47.20
21 42.45
22 57.30
23 55.65
24 56.50
25 26.95
26 59.65
27 32.10
28 29.00
29 34.75
30 21.65
变成这样的东西:
Class Frequency
(10.00 - 19.99) 6
(20.00 - 29.99) 8
(30.00 - 39.99) 4
(40.00 - 49.99) 5
(50.00 - 59.99) 7
我使用下面的代码:
factorx<-factor(cut(x, breaks=nclass.Sturges(x)))
但我得到这样的东西:
cut.default(x,breaks = nclass.Sturges(x)) 中的错误:“x”必须是数字
我应该如何使'x'数字化?
按照要求:
h <- dput(x) 结构(list(V1 = c(10.1, 46.65, 53.6, 38.5, 45.95, 12.25, 59.6, 23.3, 11.05, 58.35, 40.2, 11.05, 10.45, 26.45, 13.25, 21.15, 35, , 25.4, 47.2, 42.45, 57.3, 55.65, 56.5, 26.95, 59.65, 32.1, 29, 34.75, 21.65)), .Names = "V1", class = "data.frame", row.names = c(NA, -30L))