Skip to contents

Function to recode the default labels of a factor created by cut() from base R

Usage

relab_cut(vec, suffix = NULL, right = TRUE, lang = "fr")

Arguments

vec

The vector to be recoded

suffix

The suffix to be indicated after the values

right

TRUE if categories have been created with parameter right = TRUE in cut().

lang

The language of new labels

Value

A vector

Examples

cut(1:1000, breaks = 5, include.lowest = TRUE, right = FALSE) |>
table()
#> 
#> [0.001,201)   [201,401)   [401,600)   [600,800) [800,1e+03] 
#>         200         200         200         200         200 

cut(1:1000, breaks = 5, include.lowest = TRUE, right = FALSE) |>
relab_cut(suffix = "€", right = FALSE) |>
table()
#> 
#> Moins de 201€    201 - 400€    401 - 599€    600 - 799€  Plus de 799€ 
#>           200           200           200           200           200