我们如何使用证据权重来对R中的连续数据进行分级。例如我有一个数据:
Recency
364
91
692
13
126
4
40
93
13
33
262
12
136
21
88
16
4
19
24
89
36
5
274
125
740
6
13
715
591
443
104
853
260
125
62
357
559
155
163
16
433
91
1380
96
374
130
574
101
5
11
34
401
13
215
168
那么,根据证据权重,在不同的组中绑定此变量的命令应该是什么,或者您可以说粗略分类。
我想要的输出是: 第I组:新近度<200 第一组:新近度200-400 第I组:新近度> 400
由于
答案 0 :(得分:1)
cut(df$Recency, breaks = c(0, 200, 400, +Inf))
Recency gr
1 364 (200,400]
2 91 (0,200]
3 692 (400,Inf]
4 13 (0,200]
5 126 (0,200]
6 4 (0,200]
7 40 (0,200]
8 93 (0,200]
9 13 (0,200]
10 33 (0,200]
11 262 (200,400]
12 12 (0,200]
13 136 (0,200]
14 21 (0,200]
15 88 (0,200]
16 16 (0,200]
17 4 (0,200]
18 19 (0,200]
19 24 (0,200]
20 89 (0,200]
21 36 (0,200]
22 5 (0,200]
23 274 (200,400]
24 125 (0,200]
25 740 (400,Inf]
26 6 (0,200]
27 13 (0,200]
28 715 (400,Inf]
29 591 (400,Inf]
30 443 (400,Inf]
31 104 (0,200]
32 853 (400,Inf]
33 260 (200,400]
34 125 (0,200]
35 62 (0,200]
36 357 (200,400]
37 559 (400,Inf]
38 155 (0,200]
39 163 (0,200]
40 16 (0,200]
41 433 (400,Inf]
42 91 (0,200]
43 1380 (400,Inf]
44 96 (0,200]
45 374 (200,400]
46 130 (0,200]
47 574 (400,Inf]
48 101 (0,200]
49 5 (0,200]
50 11 (0,200]
51 34 (0,200]
52 401 (400,Inf]
53 13 (0,200]
54 215 (200,400]
55 168 (0,200]