knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "tools/README-", out.width = "100%" )
Tools for binning data
# Install rbin from CRAN install.packages("rbin") # Or the development version from GitHub # install.packages("devtools") devtools::install_github("rsquaredacademy/rbin")
rbin includes two addins for manually binning data:
rbinAddin()
rbinFactorAddin()
library(rbin)
bins <- rbin_manual(mbank, y, age, c(29, 31, 34, 36, 39, 42, 46, 51, 56)) bins # plot plot(bins)
# 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)
bins <- rbin_quantiles(mbank, y, age, 10) bins # plot plot(bins)
bins <- rbin_winsorize(mbank, y, age, 10, winsor_rate = 0.05) bins # plot plot(bins)
bins <- rbin_equal_length(mbank, y, age, 10) bins # plot plot(bins)
If you encounter a bug, please file a minimal reproducible example using reprex on github. For questions and clarifications, use StackOverflow.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.