Skip to contents

Stratify data into quartiles

Usage

wrapper_cut_quartiles(x, labels = NULL, right = TRUE)

wrapper_cut_quartiles_strat(x, strata, labels = NULL, right = TRUE)

Arguments

x

Vector of continuous values to cut.

Examples


set.seed(123)
x <- sample.int(n = 100, replace = TRUE)
x
#>   [1] 31 79 51 14 67 42 50 43 14 25 90 91 69 91 57 92  9 93 99 72 26  7 42  9 83
#>  [26] 36 78 81 43 76 15 32  7  9 41 74 23 27 60 53  7 53 27 96 38 89 34 93 69 72
#>  [51] 76 63 13 82 97 91 25 38 21 79 41 47 90 60 95 16 94  6 72 86 86 39 31 81 50
#>  [76] 34  4 13 69 25 52 22 89 32 25 87 35 40 30 12 31 30 64 99 14 93 96 71 67 23
strata <- factor(rep(c("A", "B"), each = 50))
strata 
#>   [1] A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
#>  [38] A A A A A A A A A A A A A B B B B B B B B B B B B B B B B B B B B B B B B
#>  [75] B B B B B B B B B B B B B B B B B B B B B B B B B B
#> Levels: A B

wrapper_cut_quartiles_strat(x = x, strata = strata)
#>   [1] (25%, 50%]  (75%, 100%] (50%, 75%]  [0%, 25%]   (50%, 75%]  (25%, 50%] 
#>   [7] (25%, 50%]  (25%, 50%]  [0%, 25%]   [0%, 25%]   (75%, 100%] (75%, 100%]
#>  [13] (50%, 75%]  (75%, 100%] (50%, 75%]  (75%, 100%] [0%, 25%]   (75%, 100%]
#>  [19] (75%, 100%] (50%, 75%]  [0%, 25%]   [0%, 25%]   (25%, 50%]  [0%, 25%]  
#>  [25] (75%, 100%] (25%, 50%]  (75%, 100%] (75%, 100%] (25%, 50%]  (50%, 75%] 
#>  [31] [0%, 25%]   (25%, 50%]  [0%, 25%]   [0%, 25%]   (25%, 50%]  (50%, 75%] 
#>  [37] [0%, 25%]   [0%, 25%]   (50%, 75%]  (50%, 75%]  [0%, 25%]   (50%, 75%] 
#>  [43] [0%, 25%]   (75%, 100%] (25%, 50%]  (75%, 100%] (25%, 50%]  (75%, 100%]
#>  [49] (50%, 75%]  (50%, 75%]  (50%, 75%]  (50%, 75%]  [0%, 25%]   (75%, 100%]
#>  [55] (75%, 100%] (75%, 100%] [0%, 25%]   (25%, 50%]  [0%, 25%]   (50%, 75%] 
#>  [61] (25%, 50%]  (25%, 50%]  (75%, 100%] (50%, 75%]  (75%, 100%] [0%, 25%]  
#>  [67] (75%, 100%] [0%, 25%]   (50%, 75%]  (75%, 100%] (75%, 100%] (25%, 50%] 
#>  [73] (25%, 50%]  (50%, 75%]  (50%, 75%]  (25%, 50%]  [0%, 25%]   [0%, 25%]  
#>  [79] (50%, 75%]  [0%, 25%]   (50%, 75%]  [0%, 25%]   (75%, 100%] (25%, 50%] 
#>  [85] [0%, 25%]   (75%, 100%] (25%, 50%]  (25%, 50%]  (25%, 50%]  [0%, 25%]  
#>  [91] (25%, 50%]  (25%, 50%]  (50%, 75%]  (75%, 100%] [0%, 25%]   (75%, 100%]
#>  [97] (75%, 100%] (50%, 75%]  (50%, 75%]  [0%, 25%]  
#> Levels: [0%, 25%] (25%, 50%] (50%, 75%] (75%, 100%]