-3

How can we use weight of evidence for binning continuous data in R. For e.g. I have a data:

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

So, what should be the command to bin this variable in different groups, based on Weight of evidence, or you can say coarse classing.

Output I want is: Group I: Recency <200 Group I: Recency 200-400 Group I: Recency >400

Thanks

user3619169
  • 59
  • 1
  • 1
  • 8
  • Why don't you provide a minimal [reproducible example](http://stackoverflow.com/a/5963610/640783)? Since you provide no research evidence to achieve what you want, what would be the expected output for this data set? – Paulo E. Cardoso Jun 02 '14 at 12:52

1 Answers1

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]
Paulo E. Cardoso
  • 5,778
  • 32
  • 42