-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
63 lines (42 loc) · 1.97 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# dumblump
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/dumblump)](https://CRAN.R-project.org/package=dumblump)
[![R-CMD-check](https://github.com/selkamand/dumblump/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/selkamand/dumblump/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/selkamand/dumblump/branch/master/graph/badge.svg)](https://app.codecov.io/gh/selkamand/dumblump?branch=master)
<!-- badges: end -->
Lump a numeric variable into categorical groups using 'dumblump' algorithm
# The **dumblump** algorithm:
1. Sort numbers in ascending order
2. For each number, check its distance from the previous number (the closest, lower number in dataset).
3. If distance >= threshold, define a new group. If distance < threshold, 'lump' with the group of the previous number
Disadvantages of this method
1. You can get numbers of substantially different scales in a single group. E.g. If you have a set of numbers 1, 2, 3,4, 5, 6, 7 ... 100000.
These will all be classified as a single group unless theres a 'break' of > threshold somewhere along. If this is not what you want,
explore clustering methods
## Installation
You can install the development version of dumblump like so:
``` r
#install.packages('remotes')
remotes::install_github('selkamand/dumblump')
```
## Usage
This is a basic example which shows you how to solve a common problem:
```{r example}
library(dumblump)
unlumped <- c(1, 1, 2, 5,5 , 6, 1, 12, 12)
lumped <- dumblump(unlumped, threshold = 1)
data.frame(lumped, unlumped)
```