https://github.com/rsquaredacademy/rbin
Tools for binning data
https://github.com/rsquaredacademy/rbin
binning logistic-regression rstats woe-and-iv woebinning
Last synced: 10 months ago
JSON representation
Tools for binning data
- Host: GitHub
- URL: https://github.com/rsquaredacademy/rbin
- Owner: rsquaredacademy
- License: other
- Created: 2018-10-19T14:45:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-02T16:12:13.000Z (about 3 years ago)
- Last Synced: 2024-10-31T16:12:08.719Z (over 1 year ago)
- Topics: binning, logistic-regression, rstats, woe-and-iv, woebinning
- Language: R
- Homepage: https://rbin.rsquaredacademy.com
- Size: 3.3 MB
- Stars: 13
- Watchers: 3
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "tools/README-",
out.width = "100%"
)
```
# rbin
> Tools for binning data
[](https://cran.r-project.org/package=rbin)
[](https://github.com/rsquaredacademy/rbin/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/github/rsquaredacademy/rbin?branch=master)
## Installation
```{r cran-installation, eval = FALSE}
# Install rbin from CRAN
install.packages("rbin")
# Or the development version from GitHub
# install.packages("devtools")
devtools::install_github("rsquaredacademy/rbin")
```
## Addins
rbin includes two addins for manually binning data:
- `rbinAddin()`
- `rbinFactorAddin()`
## Usage
```{r, echo=FALSE, message=FALSE}
library(rbin)
```
### Manual Binning
```{r manual}
bins <- rbin_manual(mbank, y, age, c(29, 31, 34, 36, 39, 42, 46, 51, 56))
bins
# plot
plot(bins)
```
### Combine Factor Levels
```{r factor}
# combine levels
upper <- c("secondary", "tertiary")
out <- rbin_factor_combine(mbank, education, upper, "upper")
table(out$education)
# bins
bins <- rbin_factor(out, y, education)
bins
# plot
plot(bins)
```
### Quantile Binning
```{r quantile}
bins <- rbin_quantiles(mbank, y, age, 10)
bins
# plot
plot(bins)
```
### Winsorized Binning
```{r winsorize}
bins <- rbin_winsorize(mbank, y, age, 10, winsor_rate = 0.05)
bins
# plot
plot(bins)
```
### Equal Length Binning
```{r equal_length}
bins <- rbin_equal_length(mbank, y, age, 10)
bins
# plot
plot(bins)
```
## Alternatives
- [smbinning](https://CRAN.R-project.org/package=smbinning)
- [logiBin](https://CRAN.R-project.org/package=logiBin)
- [woeBinning](https://CRAN.R-project.org/package=woeBinning)
- [binr](https://CRAN.R-project.org/package=binr)
## Getting Help
If you encounter a bug, please file a minimal reproducible example using
[reprex](https://reprex.tidyverse.org/index.html) on github. For questions
and clarifications, use [StackOverflow](https://stackoverflow.com/).
## Code of Conduct
Please note that the rbin project is released with a [Contributor Code of Conduct](https://rbin.rsquaredacademy.com/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.