jonmcalder / refactor

:bookmark: Better factor handling for R
https://jonmcalder.github.io/refactor/
MIT License
3 stars 0 forks source link

right argument without effect in cut.integer for default breaks_mode and breaks as scalars #21

Closed lorenzwalthert closed 7 years ago

lorenzwalthert commented 8 years ago

The breaks_mode is designated to resemble cut.default, however, the right argument remains without effect in cut.integer for default breaks_mode and breaks as scalars as shown below. First, look at cut.default:

cut.default(1:4, 3, right = T) [1] (0.997,2] (0.997,2] (2,3] (3,4] Levels: (0.997,2] (2,3] (3,4]

cut.default(1:4, 3, right = F) [1] [0.997,2) [2,3) [3,4) [3,4) Levels: [0.997,2) [2,3) [3,4)

The second element of the output is first part of the first bin with right = TRUE, then part of the second bin with right = FALSE. As you stated in the documentation, the implementation of cut.integer does not consider the right argument in this case.

cut(1:4, 3, right = F) [1] 1-2 1-2 3 4 Levels: 1-2 3 4

cut(1:4, 3, right = T) [1] 1-2 1-2 3 4 Levels: 1-2 3 4 Since we name the breaks_mode "default", cut.integer needs to reproduce the underlying output (not the labels obviously) of cut.default.