Skip to contents

Supply a numeric variable, e.g. Collaboration_hours, and return a character vector.

Usage

cut_hour(metric, cuts, unit = "hours", lbound = 0, ubound = 100)

Arguments

metric

A numeric variable representing hours.

cuts

A numeric vector of minimum length 3 to represent the cut points required. The minimum and maximum values provided in the vector are inclusive.

unit

String to specify the unit of the labels. Defaults to "hours".

lbound

Numeric. Specifies the lower bound (inclusive) value for the minimum label. Defaults to 0.

ubound

Numeric. Specifies the upper bound (inclusive) value for the maximum label. Defaults to 100.

Value

Character vector representing a converted categorical variable, appended with the label of the unit. See examples for more information.

Details

This is used within create_dist() for numeric to categorical conversion.

Examples

# Direct use
cut_hour(1:30, cuts = c(15, 20, 25))
#>  [1] < 15 hours    < 15 hours    < 15 hours    < 15 hours    < 15 hours   
#>  [6] < 15 hours    < 15 hours    < 15 hours    < 15 hours    < 15 hours   
#> [11] < 15 hours    < 15 hours    < 15 hours    < 15 hours    < 15 hours   
#> [16] 15 - 20 hours 15 - 20 hours 15 - 20 hours 15 - 20 hours 15 - 20 hours
#> [21] 20 - 25 hours 20 - 25 hours 20 - 25 hours 20 - 25 hours 20 - 25 hours
#> [26] 25+ hours     25+ hours     25+ hours     25+ hours     25+ hours    
#> Levels: < 15 hours 15 - 20 hours 20 - 25 hours 25+ hours

# Use on a query
cut_hour(pq_data$Collaboration_hours, cuts = c(10, 15, 20), ubound = 150)
#>    [1] 20+ hours     10 - 15 hours 10 - 15 hours 20+ hours     < 10 hours   
#>    [6] 10 - 15 hours < 10 hours    < 10 hours    < 10 hours    10 - 15 hours
#>   [11] 10 - 15 hours 15 - 20 hours 20+ hours     < 10 hours    20+ hours    
#>   [16] < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours
#>   [21] 10 - 15 hours 15 - 20 hours 10 - 15 hours 10 - 15 hours < 10 hours   
#>   [26] < 10 hours    20+ hours     15 - 20 hours 10 - 15 hours < 10 hours   
#>   [31] 10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours     20+ hours    
#>   [36] 15 - 20 hours 15 - 20 hours 15 - 20 hours 10 - 15 hours 10 - 15 hours
#>   [41] < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours 15 - 20 hours
#>   [46] 20+ hours     20+ hours     10 - 15 hours 20+ hours     10 - 15 hours
#>   [51] < 10 hours    15 - 20 hours 15 - 20 hours 20+ hours     < 10 hours   
#>   [56] < 10 hours    10 - 15 hours 10 - 15 hours 15 - 20 hours 20+ hours    
#>   [61] 10 - 15 hours 10 - 15 hours < 10 hours    < 10 hours    < 10 hours   
#>   [66] 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours < 10 hours   
#>   [71] 10 - 15 hours 10 - 15 hours < 10 hours    < 10 hours    10 - 15 hours
#>   [76] 10 - 15 hours 15 - 20 hours 15 - 20 hours < 10 hours    10 - 15 hours
#>   [81] 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>   [86] 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours    
#>   [91] 10 - 15 hours 20+ hours     15 - 20 hours 20+ hours     < 10 hours   
#>   [96] 20+ hours     10 - 15 hours 15 - 20 hours < 10 hours    10 - 15 hours
#>  [101] 20+ hours     10 - 15 hours 10 - 15 hours 20+ hours     10 - 15 hours
#>  [106] < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours    15 - 20 hours
#>  [111] < 10 hours    10 - 15 hours 20+ hours     10 - 15 hours 20+ hours    
#>  [116] < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [121] < 10 hours    15 - 20 hours < 10 hours    < 10 hours    10 - 15 hours
#>  [126] < 10 hours    20+ hours     10 - 15 hours 10 - 15 hours < 10 hours   
#>  [131] < 10 hours    10 - 15 hours 10 - 15 hours 20+ hours     20+ hours    
#>  [136] 15 - 20 hours 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>  [141] 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [146] 20+ hours     20+ hours     15 - 20 hours 20+ hours     < 10 hours   
#>  [151] 10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours     < 10 hours   
#>  [156] < 10 hours    10 - 15 hours 10 - 15 hours 15 - 20 hours 20+ hours    
#>  [161] 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [166] < 10 hours    10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>  [171] 15 - 20 hours 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours
#>  [176] < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours   
#>  [181] < 10 hours    15 - 20 hours 10 - 15 hours 15 - 20 hours 10 - 15 hours
#>  [186] < 10 hours    15 - 20 hours 10 - 15 hours 10 - 15 hours 20+ hours    
#>  [191] < 10 hours    20+ hours     15 - 20 hours 20+ hours     < 10 hours   
#>  [196] 10 - 15 hours < 10 hours    15 - 20 hours 10 - 15 hours 10 - 15 hours
#>  [201] 20+ hours     10 - 15 hours 10 - 15 hours 20+ hours     10 - 15 hours
#>  [206] 10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours
#>  [211] 10 - 15 hours 15 - 20 hours 20+ hours     15 - 20 hours 20+ hours    
#>  [216] 10 - 15 hours < 10 hours    15 - 20 hours 15 - 20 hours 10 - 15 hours
#>  [221] 10 - 15 hours 15 - 20 hours 10 - 15 hours 15 - 20 hours 10 - 15 hours
#>  [226] 10 - 15 hours 20+ hours     10 - 15 hours 15 - 20 hours < 10 hours   
#>  [231] 15 - 20 hours 10 - 15 hours 10 - 15 hours 20+ hours     20+ hours    
#>  [236] 15 - 20 hours 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours
#>  [241] 10 - 15 hours 10 - 15 hours 15 - 20 hours < 10 hours    < 10 hours   
#>  [246] 20+ hours     20+ hours     10 - 15 hours 20+ hours     < 10 hours   
#>  [251] 10 - 15 hours < 10 hours    15 - 20 hours 20+ hours     10 - 15 hours
#>  [256] 10 - 15 hours 15 - 20 hours 15 - 20 hours 20+ hours     20+ hours    
#>  [261] 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>  [266] 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>  [271] 15 - 20 hours 15 - 20 hours 15 - 20 hours < 10 hours    10 - 15 hours
#>  [276] 10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours    < 10 hours   
#>  [281] 10 - 15 hours 10 - 15 hours < 10 hours    15 - 20 hours 15 - 20 hours
#>  [286] 10 - 15 hours 10 - 15 hours 10 - 15 hours 15 - 20 hours 20+ hours    
#>  [291] 10 - 15 hours 20+ hours     10 - 15 hours 20+ hours     < 10 hours   
#>  [296] 15 - 20 hours < 10 hours    10 - 15 hours 15 - 20 hours 10 - 15 hours
#>  [301] 20+ hours     10 - 15 hours 15 - 20 hours 20+ hours     10 - 15 hours
#>  [306] < 10 hours    10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>  [311] < 10 hours    10 - 15 hours 20+ hours     < 10 hours    20+ hours    
#>  [316] < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours   
#>  [321] < 10 hours    15 - 20 hours 10 - 15 hours < 10 hours    10 - 15 hours
#>  [326] < 10 hours    20+ hours     15 - 20 hours 10 - 15 hours < 10 hours   
#>  [331] < 10 hours    10 - 15 hours 10 - 15 hours 20+ hours     20+ hours    
#>  [336] 10 - 15 hours < 10 hours    < 10 hours    < 10 hours    < 10 hours   
#>  [341] 10 - 15 hours < 10 hours    < 10 hours    15 - 20 hours < 10 hours   
#>  [346] 20+ hours     20+ hours     10 - 15 hours 20+ hours     < 10 hours   
#>  [351] < 10 hours    < 10 hours    10 - 15 hours 20+ hours     < 10 hours   
#>  [356] < 10 hours    10 - 15 hours < 10 hours    10 - 15 hours 20+ hours    
#>  [361] 10 - 15 hours 10 - 15 hours 15 - 20 hours < 10 hours    20+ hours    
#>  [366] < 10 hours    10 - 15 hours < 10 hours    10 - 15 hours < 10 hours   
#>  [371] < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours    < 10 hours   
#>  [376] < 10 hours    < 10 hours    10 - 15 hours < 10 hours    10 - 15 hours
#>  [381] < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [386] 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours 20+ hours    
#>  [391] < 10 hours    20+ hours     20+ hours     20+ hours     10 - 15 hours
#>  [396] 15 - 20 hours < 10 hours    15 - 20 hours 20+ hours     < 10 hours   
#>  [401] 20+ hours     10 - 15 hours 10 - 15 hours 20+ hours     10 - 15 hours
#>  [406] 10 - 15 hours 10 - 15 hours < 10 hours    < 10 hours    10 - 15 hours
#>  [411] 10 - 15 hours 10 - 15 hours 20+ hours     < 10 hours    20+ hours    
#>  [416] < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours 15 - 20 hours
#>  [421] 10 - 15 hours 15 - 20 hours 10 - 15 hours 15 - 20 hours 10 - 15 hours
#>  [426] < 10 hours    20+ hours     10 - 15 hours 15 - 20 hours 10 - 15 hours
#>  [431] < 10 hours    10 - 15 hours 10 - 15 hours 20+ hours     20+ hours    
#>  [436] 10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours
#>  [441] < 10 hours    10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>  [446] 20+ hours     20+ hours     10 - 15 hours 20+ hours     < 10 hours   
#>  [451] 10 - 15 hours 10 - 15 hours 15 - 20 hours 20+ hours     < 10 hours   
#>  [456] 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours    
#>  [461] 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours   
#>  [466] 15 - 20 hours 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>  [471] 10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours
#>  [476] < 10 hours    < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours
#>  [481] < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [486] 10 - 15 hours < 10 hours    10 - 15 hours 15 - 20 hours 20+ hours    
#>  [491] 10 - 15 hours 20+ hours     15 - 20 hours 20+ hours     < 10 hours   
#>  [496] 15 - 20 hours < 10 hours    15 - 20 hours < 10 hours    10 - 15 hours
#>  [501] 20+ hours     20+ hours     10 - 15 hours 20+ hours     10 - 15 hours
#>  [506] < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours    20+ hours    
#>  [511] 10 - 15 hours 15 - 20 hours 20+ hours     10 - 15 hours 20+ hours    
#>  [516] < 10 hours    < 10 hours    15 - 20 hours 15 - 20 hours 10 - 15 hours
#>  [521] 15 - 20 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours   
#>  [526] < 10 hours    20+ hours     20+ hours     < 10 hours    < 10 hours   
#>  [531] < 10 hours    15 - 20 hours < 10 hours    20+ hours     20+ hours    
#>  [536] 20+ hours     < 10 hours    10 - 15 hours 15 - 20 hours 15 - 20 hours
#>  [541] 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [546] 20+ hours     20+ hours     15 - 20 hours 20+ hours     < 10 hours   
#>  [551] < 10 hours    < 10 hours    10 - 15 hours 20+ hours     < 10 hours   
#>  [556] 10 - 15 hours 10 - 15 hours 15 - 20 hours 10 - 15 hours 20+ hours    
#>  [561] 15 - 20 hours 10 - 15 hours 15 - 20 hours < 10 hours    15 - 20 hours
#>  [566] 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>  [571] < 10 hours    15 - 20 hours 10 - 15 hours < 10 hours    10 - 15 hours
#>  [576] 10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours    < 10 hours   
#>  [581] 10 - 15 hours 10 - 15 hours 15 - 20 hours 10 - 15 hours 15 - 20 hours
#>  [586] < 10 hours    < 10 hours    < 10 hours    10 - 15 hours 20+ hours    
#>  [591] 15 - 20 hours 20+ hours     15 - 20 hours 20+ hours     10 - 15 hours
#>  [596] 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours   
#>  [601] 20+ hours     15 - 20 hours 15 - 20 hours 20+ hours     10 - 15 hours
#>  [606] 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [611] 15 - 20 hours 20+ hours     20+ hours     10 - 15 hours 20+ hours    
#>  [616] 10 - 15 hours 10 - 15 hours 20+ hours     10 - 15 hours 15 - 20 hours
#>  [621] 15 - 20 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [626] 10 - 15 hours 20+ hours     15 - 20 hours 15 - 20 hours 10 - 15 hours
#>  [631] 15 - 20 hours 15 - 20 hours 10 - 15 hours 20+ hours     20+ hours    
#>  [636] 15 - 20 hours 10 - 15 hours 15 - 20 hours 10 - 15 hours 15 - 20 hours
#>  [641] 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [646] 20+ hours     20+ hours     20+ hours     20+ hours     10 - 15 hours
#>  [651] 10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours     < 10 hours   
#>  [656] 10 - 15 hours 15 - 20 hours 10 - 15 hours 10 - 15 hours 20+ hours    
#>  [661] 15 - 20 hours 10 - 15 hours 15 - 20 hours < 10 hours    10 - 15 hours
#>  [666] 15 - 20 hours 15 - 20 hours 10 - 15 hours 15 - 20 hours 10 - 15 hours
#>  [671] 15 - 20 hours 10 - 15 hours 20+ hours     10 - 15 hours 15 - 20 hours
#>  [676] 10 - 15 hours 15 - 20 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [681] 10 - 15 hours 10 - 15 hours 10 - 15 hours 15 - 20 hours 20+ hours    
#>  [686] 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours    
#>  [691] 10 - 15 hours 20+ hours     15 - 20 hours 20+ hours     10 - 15 hours
#>  [696] 20+ hours     < 10 hours    15 - 20 hours 10 - 15 hours 10 - 15 hours
#>  [701] 20+ hours     15 - 20 hours < 10 hours    20+ hours     10 - 15 hours
#>  [706] < 10 hours    < 10 hours    < 10 hours    < 10 hours    10 - 15 hours
#>  [711] < 10 hours    15 - 20 hours 20+ hours     < 10 hours    20+ hours    
#>  [716] < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours   
#>  [721] 10 - 15 hours < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours
#>  [726] < 10 hours    20+ hours     15 - 20 hours 10 - 15 hours < 10 hours   
#>  [731] 10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours     20+ hours    
#>  [736] 15 - 20 hours < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours
#>  [741] 10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours
#>  [746] 20+ hours     20+ hours     10 - 15 hours 20+ hours     < 10 hours   
#>  [751] < 10 hours    < 10 hours    10 - 15 hours 20+ hours     < 10 hours   
#>  [756] < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours    
#>  [761] 10 - 15 hours < 10 hours    15 - 20 hours 10 - 15 hours 20+ hours    
#>  [766] < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours   
#>  [771] 10 - 15 hours 10 - 15 hours 20+ hours     < 10 hours    10 - 15 hours
#>  [776] < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [781] < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours
#>  [786] < 10 hours    < 10 hours    < 10 hours    10 - 15 hours 20+ hours    
#>  [791] < 10 hours    20+ hours     15 - 20 hours 20+ hours     10 - 15 hours
#>  [796] 10 - 15 hours < 10 hours    < 10 hours    20+ hours     < 10 hours   
#>  [801] 20+ hours     10 - 15 hours 10 - 15 hours 20+ hours     10 - 15 hours
#>  [806] < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours    10 - 15 hours
#>  [811] 10 - 15 hours 15 - 20 hours 20+ hours     < 10 hours    20+ hours    
#>  [816] 10 - 15 hours < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [821] < 10 hours    15 - 20 hours < 10 hours    10 - 15 hours < 10 hours   
#>  [826] < 10 hours    20+ hours     15 - 20 hours 10 - 15 hours 15 - 20 hours
#>  [831] < 10 hours    < 10 hours    < 10 hours    20+ hours     20+ hours    
#>  [836] 10 - 15 hours < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours
#>  [841] 10 - 15 hours < 10 hours    < 10 hours    10 - 15 hours < 10 hours   
#>  [846] 20+ hours     20+ hours     < 10 hours    20+ hours     < 10 hours   
#>  [851] 10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours     < 10 hours   
#>  [856] < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours    
#>  [861] < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours    < 10 hours   
#>  [866] < 10 hours    < 10 hours    < 10 hours    10 - 15 hours < 10 hours   
#>  [871] 10 - 15 hours < 10 hours    20+ hours     < 10 hours    < 10 hours   
#>  [876] 10 - 15 hours < 10 hours    < 10 hours    < 10 hours    < 10 hours   
#>  [881] < 10 hours    < 10 hours    < 10 hours    < 10 hours    10 - 15 hours
#>  [886] 10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours    20+ hours    
#>  [891] 15 - 20 hours 20+ hours     10 - 15 hours 20+ hours     < 10 hours   
#>  [896] 10 - 15 hours < 10 hours    15 - 20 hours 10 - 15 hours 10 - 15 hours
#>  [901] 20+ hours     10 - 15 hours 15 - 20 hours 20+ hours     10 - 15 hours
#>  [906] < 10 hours    < 10 hours    < 10 hours    < 10 hours    10 - 15 hours
#>  [911] < 10 hours    15 - 20 hours 20+ hours     10 - 15 hours 20+ hours    
#>  [916] < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours   
#>  [921] 15 - 20 hours < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours
#>  [926] < 10 hours    20+ hours     15 - 20 hours < 10 hours    10 - 15 hours
#>  [931] 15 - 20 hours 20+ hours     < 10 hours    20+ hours     20+ hours    
#>  [936] 10 - 15 hours < 10 hours    < 10 hours    15 - 20 hours 10 - 15 hours
#>  [941] 15 - 20 hours < 10 hours    < 10 hours    15 - 20 hours 15 - 20 hours
#>  [946] 20+ hours     20+ hours     20+ hours     20+ hours     10 - 15 hours
#>  [951] 10 - 15 hours 10 - 15 hours 15 - 20 hours 20+ hours     < 10 hours   
#>  [956] < 10 hours    10 - 15 hours < 10 hours    < 10 hours    20+ hours    
#>  [961] 10 - 15 hours < 10 hours    10 - 15 hours < 10 hours    10 - 15 hours
#>  [966] < 10 hours    < 10 hours    10 - 15 hours 20+ hours     < 10 hours   
#>  [971] 15 - 20 hours 10 - 15 hours 20+ hours     10 - 15 hours 10 - 15 hours
#>  [976] < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours < 10 hours   
#>  [981] 10 - 15 hours 10 - 15 hours 10 - 15 hours 10 - 15 hours < 10 hours   
#>  [986] < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours 20+ hours    
#>  [991] < 10 hours    20+ hours     15 - 20 hours 20+ hours     < 10 hours   
#>  [996] < 10 hours    < 10 hours    10 - 15 hours 10 - 15 hours 10 - 15 hours
#> Levels: < 10 hours 10 - 15 hours 15 - 20 hours 20+ hours