rbin 0.3.0 handles missing predictors, tied values, winsorized scoring and missing responses so every record lands in a bin you can explain.
Author
Aravind Hebbali
Published
November 28, 2026
rbin 0.3.0
rbin bins predictors for scorecards and reports the weight of evidence and information value of every bin.
It works on numeric and categorical predictors, offers equal-frequency, quantile, equal-length, winsorized and manual cuts, and builds dummy variables from the bins.
The examples use mbank, the package’s bank marketing data; treat y as the good/bad outcome you would model.
Binning a predictor
A common starting point: rbin_quantiles() cuts one numeric predictor into groups of equal frequency and reports what each group holds. balance, the customer’s average yearly account balance, is known before any contact, so it goes into five bins:
Code
bins_balance <-rbin_quantiles(mbank[, c("balance", "y")], y, balance, bins =5)bins_balance
The cuts fall at 25, 283, 715 and 1,804, and subscriptions rise with balance: 61 of the 901 customers in the lowest bin subscribed, against 147 of the 905 in the highest. The weight of evidence falls from 0.58 to -0.41 (here a positive weight means a bin with fewer subscribers than average), and the information value for balance is 0.1 (rounded; about 0.095), a modest predictor to weigh against the others.
plot() draws those weights in bin order:
Code
plot(bins_balance)
Figure 1
The appeal is the single call: a count and a weight for each bin, and one information value to set balance beside the other predictors you are considering.
What 0.3.0 adds
rbin 0.3.0 keeps every record in a scorecard in a bin you can explain: missing predictors, repeated values, extreme values and missing responses are each handled, and the package tells you what it did. It also brings in the 0.2.2 and 0.2.3 work, which never reached CRAN. If you saved binning results from 0.2.1, refit before you score; the Behaviour changes block lists what moves.
Every customer lands in a bin
Where does a customer with no age go? mbank records the outcome of a bank’s term-deposit campaign for 4,521 customers, with the age of each. The data has no missing values, so four ages are blanked to mimic incomplete records before age is binned into four groups:
Code
d <- mbank[, c("age", "y")]missing_rows <-c(which(d$y =="0")[c(2, 5, 9)], which(d$y =="1")[4])d$age[missing_rows] <-NAbins_age <-rbin_equal_freq(d, y, age, bins =4)bins_age
Binning Summary
------------------------------------
Method Equal Frequency
Response y
Predictor age
Bins 5
Count 4521
Goods 517
Bads 4004
Entropy 0.51
Information Value 0.04
lower_cut upper_cut bin_count good bad good_rate woe iv
1 -Inf 34 1289 167 1122 0.12955780 -0.1421320 0.006082912
2 34 40 1070 102 968 0.09532710 0.2032530 0.009037883
3 40 49 1055 95 960 0.09004739 0.2660501 0.014900888
4 49 Inf 1103 152 951 0.13780598 -0.2133727 0.012053720
5 NA NA 4 1 3 0.25000000 -0.9483940 0.001123833
entropy
1 0.5562242
2 0.4540054
3 0.4366280
4 0.5784639
5 0.8112781
The summary has five bins: four intervals cut from the 4,517 customers who have an age (34, 40 and 49), and a final group of 4 rows marked NA in both cut columns (#69). The top interval holds 1,103 rows, and the total information value reads 0.04. The plot shows the weight of evidence for each bin, with the group of rows without an age at the end:
Code
plot(bins_age)
Figure 2
In 0.2.1 those four rows sat inside the top interval, whose upper cut printed NA; the cuts were 33, 39 and 48, and the total information value read 0.06.
Bins that match your data
Can a predictor with mostly one value fill five bins? Most customers in mbank had no earlier contact: previous is zero for 3,686 of them. Ask for five equal-frequency bins:
Code
rbin_equal_freq(mbank[, c("previous", "y")], y, previous, bins =5)
Requested 5 equal-frequency bins; returning 2 non-missing bin(s) because tied values are kept together.
Binning Summary
------------------------------------
Method Equal Frequency
Response y
Predictor previous
Bins 2
Count 4521
Goods 517
Bads 4004
Entropy 0.5
Information Value 0.2
lower_cut upper_cut bin_count good bad good_rate woe iv
1 -Inf 1 3686 334 3352 0.09061313 0.2591652 0.04953373
2 1 Inf 835 183 652 0.21916168 -0.7764479 0.14840094
entropy
1 0.4385131
2 0.7586338
Two bins come back, and the message says why. A run of identical values cannot be split across a boundary, so the first bin holds the 3,686 customers with previous of 0 and the second holds the rest.
In 0.2.1 the cuts went through the ties: five bins, four of them labelled 0 to 0, and rbin_create() stopped with an error on that summary.
Score new customers safely
Can a saved set of bins score a customer outside the training range? Credit teams cap a long tail so a handful of extreme values do not set the cuts. balance runs from -1,941 to 57,435 and is known before contact, so cap it at 0 and 5,000 and ask for four bins:
The cuts are 1,250, 2,500 and 3,750, inside the clamps; the first bin holds 3,262 customers, and the top bin holds 399 with a weight of evidence of -0.37, for an information value of 0.06. The clamps are stored with the bins, so scoring new records uses the same ones:
Each value gets one row, with one dummy column marked for the bin it falls in; -500 falls below the floor into the first bin, and 5,000 and 9,000 sit at or above the ceiling in the last one.
In 0.2.1 a floor of 0 was not handled: every cut printed as the raw minimum (-1941), each of the four rows counted all 4,521 customers for an information value of 0, and the object it saved could not be scored at all: rbin_create() stopped on a length mismatch.
rbin takes its cut points from finite predictor values up to 1e300 in absolute value and stops beyond that with a message.
Clear messages for dropped rows
Where do rows with no outcome go? Three responses are blanked to mimic missing outcomes in this extract:
Code
d <- mbank[, c("age", "y")]d$y[c(3, 7, 11)] <-NArbin_equal_freq(d, y, age, bins =4)
Warning: Dropping 3 rows with missing response.
Binning Summary
------------------------------------
Method Equal Frequency
Response y
Predictor age
Bins 4
Count 4518
Goods 516
Bads 4002
Entropy 0.51
Information Value 0.04
lower_cut upper_cut bin_count good bad good_rate woe iv
1 -Inf 34 1289 167 1122 0.12955780 -0.1435685 0.006214159
2 34 40 1069 101 968 0.09448082 0.2116688 0.009766955
3 40 49 1055 95 960 0.09004739 0.2646136 0.014757908
4 49 Inf 1105 153 952 0.13846154 -0.2203156 0.012917231
entropy
1 0.5562242
2 0.4512520
3 0.4366280
4 0.5801955
The call drops the three rows, says how many it removed, and summarises the 4,518 that remain: 516 goods, 4,002 bads and an information value of 0.04.
In 0.2.1 the rows stayed in the count and the summary returned NA for goods, bads, entropy and information value in every bin that held one, while the count still read 4,521.
Behaviour changes
If you report bin counts, weight of evidence, information value or dummy variables from bins fitted with 0.2.1, refit before you score.
What you saved
What moves in 0.3.0
Equal-frequency bins with missing predictors
Missing rows get their own bin, the cuts come from rows with a value, and the top interval count and total information value move (1,130 to 1,103; 0.06 to 0.04 in the age example)
Bins on tied values
Tied values stay in one bin: ask for 5, get the 2 it can build, and the dummies follow the bins returned
Winsorized bins
The clamps bound the fit and the score; a saved 0.2.1 object ignored them, could not be scored, and rbin_create() stopped on a length mismatch
Bins with missing responses
Rows without an outcome are dropped with a warning that gives the count, and the summary describes the complete cases
Other improvements
Bare column names, strings and variables that hold names work in every numeric binning function and in rbin_create(), including names with spaces or punctuation.
Character responses are sorted in the same order on every machine, so the second value is always the event; declare the response as a factor to choose the event level yourself.
Empty intervals keep zero counts and undefined rates and weight of evidence, with zero information value and entropy, instead of dropping out of the summary.
rbin_factor() groups on integer IDs, so two distinct categories whose printed text looks the same stay separate, and an explicit NA factor level stays separate from a missing code.
rbin_create() keeps bin order, keeps a column for a bin with no rows, makes colliding boundary labels distinct, and scores values outside the training range into the outer intervals (#67).
A character predictor is no longer ignored: the numeric methods stop and point to rbin_factor() or rbin_factor_create() (#70). 64-bit integers (integer64) and time differences (difftime) are refused with a message showing how to convert them.
Every method and both addins accept data.table input, and a response that is not 0/1, logical or a two-level factor or character stops with a message.
The package no longer checks CRAN for updates when it is attached.
What’s next
Known issue: a bin with no events or no non-events gets an infinite weight of evidence and information value (#68).
The other open reports concern input checks and messages, not results: argument names in errors and the addins (#80), a one-column matrix predictor (#79), and the conversion hints for date and time predictors (#77). The first two are fixed on the development branch and will be in the next release.
Install from CRAN
Code
install.packages("rbin")
You can see a full list of changes in the release notes.
How we checked: every 0.3.0 number in this post comes from the code shown, run on CRAN rbin 0.3.0. The 0.2.1 figures come from the same scripts run on CRAN 0.2.1; the scripts and transcripts are in this post’s runs/ folder.