Three types of labels (levels) are supported: “cut.default” (Interval labels returned by cut as default), “left” (Left boundary of intervals), and “right” (Right boundary of intervals).

cutInterval(
  x,
  step = 1,
  labelOption = c("cut.default", "left", "right"),
  include.lowest = FALSE,
  right = TRUE,
  dig.lab = 3,
  ordered_result = FALSE,
  ...
)

Arguments

x

A vector of numbers

step

Step size.

labelOption

How is the label displayed.See details section.

include.lowest

Logical, passed to cut

right

Logial, passed to cut

dig.lab

See cut

ordered_result

See cut

...

Other parameters that are passed to cut

Value

A vector of factors

See also

Author

Jitao David Zhang <jitao_david.zhang@roche.com>

Examples


testNum <- rnorm(100)
(testFac <- cutInterval(testNum, step=1, labelOption="cut.default"))
#>   [1] (1,2]   (0,1]   (1,2]   (-1,0]  (-1,0]  (0,1]   (-1,0]  (0,1]   (-2,-1]
#>  [10] (0,1]   (1,2]   (-3,-2] (-2,-1] (0,1]   (-3,-2] (-1,0]  (-2,-1] (-1,0] 
#>  [19] (-1,0]  (-1,0]  (-1,0]  (-1,0]  (-1,0]  (0,1]   (-3,-2] (-2,-1] (-3,-2]
#>  [28] (0,1]   (-1,0]  (0,1]   (-1,0]  (0,1]   (-2,-1] (-1,0]  (0,1]   (-2,-1]
#>  [37] (-1,0]  (1,2]   (-1,0]  (0,1]   (-1,0]  (1,2]   (0,1]   (0,1]   (0,1]  
#>  [46] (-1,0]  (0,1]   (-1,0]  (1,2]   (-1,0]  (0,1]   (-2,-1] (0,1]   (-1,0] 
#>  [55] (-1,0]  (-2,-1] (-1,0]  (-1,0]  (-1,0]  (0,1]   (-2,-1] (0,1]   (-2,-1]
#>  [64] (0,1]   (-1,0]  (-1,0]  (-1,0]  (-1,0]  (0,1]   (0,1]   (-1,0]  (0,1]  
#>  [73] (1,2]   (0,1]   (0,1]   (-1,0]  (-1,0]  (0,1]   (1,2]   (-3,-2] (0,1]  
#>  [82] (0,1]   (0,1]   (-1,0]  (-1,0]  (0,1]   (1,2]   (-1,0]  (1,2]   (-3,-2]
#>  [91] (1,2]   (0,1]   (0,1]   (1,2]   (0,1]   (-1,0]  (-1,0]  (-1,0]  (0,1]  
#> [100] (0,1]  
#> Levels: (-3,-2] (-2,-1] (-1,0] (0,1] (1,2]

## compare the result to
(testFacCut <- cut(testNum, 10))
#>   [1] (0.892,1.37]     (0.42,0.892]     (1.37,1.84]      (-0.999,-0.526] 
#>   [5] (-0.526,-0.0533] (0.42,0.892]     (-0.999,-0.526]  (-0.0533,0.42]  
#>   [9] (-1.94,-1.47]    (-0.0533,0.42]   (1.37,1.84]      (-2.9,-2.42]    
#>  [13] (-1.94,-1.47]    (0.42,0.892]     (-2.42,-1.94]    (-0.999,-0.526] 
#>  [17] (-1.94,-1.47]    (-0.999,-0.526]  (-0.999,-0.526]  (-0.999,-0.526] 
#>  [21] (-0.999,-0.526]  (-0.526,-0.0533] (-0.999,-0.526]  (0.42,0.892]    
#>  [25] (-2.9,-2.42]     (-1.94,-1.47]    (-2.42,-1.94]    (0.42,0.892]    
#>  [29] (-0.526,-0.0533] (0.892,1.37]     (-0.526,-0.0533] (0.42,0.892]    
#>  [33] (-1.47,-0.999]   (-0.526,-0.0533] (0.42,0.892]     (-1.94,-1.47]   
#>  [37] (-0.526,-0.0533] (0.892,1.37]     (-0.526,-0.0533] (0.892,1.37]    
#>  [41] (-0.526,-0.0533] (0.892,1.37]     (-0.0533,0.42]   (0.42,0.892]    
#>  [45] (0.42,0.892]     (-0.526,-0.0533] (0.42,0.892]     (-0.526,-0.0533]
#>  [49] (1.37,1.84]      (-0.526,-0.0533] (0.42,0.892]     (-1.94,-1.47]   
#>  [53] (0.42,0.892]     (-0.999,-0.526]  (-0.526,-0.0533] (-1.94,-1.47]   
#>  [57] (-0.526,-0.0533] (-0.999,-0.526]  (-0.999,-0.526]  (0.42,0.892]    
#>  [61] (-1.47,-0.999]   (-0.0533,0.42]   (-1.47,-0.999]   (-0.0533,0.42]  
#>  [65] (-0.999,-0.526]  (-0.526,-0.0533] (-0.999,-0.526]  (-0.526,-0.0533]
#>  [69] (-0.0533,0.42]   (0.42,0.892]     (-0.526,-0.0533] (0.42,0.892]    
#>  [73] (0.892,1.37]     (0.42,0.892]     (0.42,0.892]     (-0.999,-0.526] 
#>  [77] (-0.526,-0.0533] (-0.0533,0.42]   (1.37,1.84]      (-2.42,-1.94]   
#>  [81] (-0.0533,0.42]   (-0.0533,0.42]   (-0.0533,0.42]   (-0.999,-0.526] 
#>  [85] (-0.999,-0.526]  (0.42,0.892]     (0.892,1.37]     (-0.999,-0.526] 
#>  [89] (1.37,1.84]      (-2.9,-2.42]     (0.892,1.37]     (0.42,0.892]    
#>  [93] (-0.0533,0.42]   (0.892,1.37]     (-0.0533,0.42]   (-0.999,-0.526] 
#>  [97] (-0.999,-0.526]  (-0.526,-0.0533] (0.42,0.892]     (0.892,1.37]    
#> 10 Levels: (-2.9,-2.42] (-2.42,-1.94] (-1.94,-1.47] ... (1.37,1.84]