-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
120 lines (86 loc) · 2.58 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "tools/README-",
out.width = "100%"
)
```
# rbin
> Tools for binning data
<!-- badges: start -->
[![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)
<!-- badges: end -->
## 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.