-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
categorize() add labels="range" option (#549)
* categorize() add labels="range" option Fixes #548 * add test, docs * lintr * add option to decide on exclusive/inclusive breaks * docs
- Loading branch information
1 parent
ea2f16f
commit 77d67f4
Showing
4 changed files
with
144 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# categorize labelling ranged | ||
|
||
Code | ||
categorize(mtcars$mpg, "equal_length", n_groups = 5) | ||
Output | ||
[1] 3 3 3 3 2 2 1 3 3 2 2 2 2 2 1 1 1 5 5 5 3 2 2 1 2 4 4 5 2 2 1 3 | ||
|
||
--- | ||
|
||
Code | ||
categorize(mtcars$mpg, "equal_length", n_groups = 5, labels = "range") | ||
Output | ||
[1] [19.8,24.5) [19.8,24.5) [19.8,24.5) [19.8,24.5) [15.1,19.8) [15.1,19.8) | ||
[7] [10.4,15.1) [19.8,24.5) [19.8,24.5) [15.1,19.8) [15.1,19.8) [15.1,19.8) | ||
[13] [15.1,19.8) [15.1,19.8) [10.4,15.1) [10.4,15.1) [10.4,15.1) [29.2,33.9] | ||
[19] [29.2,33.9] [29.2,33.9] [19.8,24.5) [15.1,19.8) [15.1,19.8) [10.4,15.1) | ||
[25] [15.1,19.8) [24.5,29.2) [24.5,29.2) [29.2,33.9] [15.1,19.8) [15.1,19.8) | ||
[31] [10.4,15.1) [19.8,24.5) | ||
Levels: [10.4,15.1) [15.1,19.8) [19.8,24.5) [24.5,29.2) [29.2,33.9] | ||
|
||
--- | ||
|
||
Code | ||
categorize(mtcars$mpg, "equal_length", n_groups = 5, labels = "observed") | ||
Output | ||
[1] (21-24.4) (21-24.4) (21-24.4) (21-24.4) (15.2-19.7) (15.2-19.7) | ||
[7] (10.4-15) (21-24.4) (21-24.4) (15.2-19.7) (15.2-19.7) (15.2-19.7) | ||
[13] (15.2-19.7) (15.2-19.7) (10.4-15) (10.4-15) (10.4-15) (30.4-33.9) | ||
[19] (30.4-33.9) (30.4-33.9) (21-24.4) (15.2-19.7) (15.2-19.7) (10.4-15) | ||
[25] (15.2-19.7) (26-27.3) (26-27.3) (30.4-33.9) (15.2-19.7) (15.2-19.7) | ||
[31] (10.4-15) (21-24.4) | ||
Levels: (10.4-15) (15.2-19.7) (21-24.4) (26-27.3) (30.4-33.9) | ||
|
||
--- | ||
|
||
Code | ||
categorize(mtcars$mpg, "equal_length", n_groups = 5, labels = "observed", | ||
breaks = "inclusive") | ||
Output | ||
[1] (21-24.4) (21-24.4) (21-24.4) (21-24.4) (15.2-19.7) (15.2-19.7) | ||
[7] (10.4-15) (21-24.4) (21-24.4) (15.2-19.7) (15.2-19.7) (15.2-19.7) | ||
[13] (15.2-19.7) (15.2-19.7) (10.4-15) (10.4-15) (10.4-15) (30.4-33.9) | ||
[19] (30.4-33.9) (30.4-33.9) (21-24.4) (15.2-19.7) (15.2-19.7) (10.4-15) | ||
[25] (15.2-19.7) (26-27.3) (26-27.3) (30.4-33.9) (15.2-19.7) (15.2-19.7) | ||
[31] (10.4-15) (21-24.4) | ||
Levels: (10.4-15) (15.2-19.7) (21-24.4) (26-27.3) (30.4-33.9) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters