An open API service indexing awesome lists of open source software.

https://github.com/rsquaredacademy/rbin

Tools for binning data
https://github.com/rsquaredacademy/rbin

binning logistic-regression rstats woe-and-iv woebinning

Last synced: 4 months ago
JSON representation

Tools for binning data

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

[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/rbin)](https://cran.r-project.org/package=rbin)
[![R-CMD-check](https://github.com/rsquaredacademy/rbin/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rsquaredacademy/rbin/actions/workflows/R-CMD-check.yaml)
[![Coverage status](https://codecov.io/gh/rsquaredacademy/rbin/branch/master/graph/badge.svg)](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.