Function to recode the default labels of a factor created by cut() from base R into more intuitive labels.
Arguments
- vec
The vector to be recoded. It should be produced by
cut(). Notice that the labels may not include scientific notation. Thus, incut(),dig.labargument should be high enough in order to produce labels without scientific notation.- suffix
The suffix to be indicated after the values. Usualy, the unit of the variable will be used (e.g. euros, percents). Default is
NULL, for no suffix.- right
TRUEif categories have been created with parameterright = TRUEincut().FALSEif categories have been created with parameterright = FALSEincut(). Default isTRUE.- lang
Language of new labels. Possibilities are
"fr"(french),"nl"(dutch) and"en"(english). Default is"fr".
Examples
cut(1:1000, breaks = 5, include.lowest = TRUE, right = FALSE, dig.lab = 4) |>
table()
#>
#> [0.001,200.8) [200.8,400.6) [400.6,600.4) [600.4,800.2) [800.2,1001]
#> 200 200 200 200 200
cut(1:1000, breaks = 5, include.lowest = TRUE, right = FALSE, dig.lab = 4) |>
relab_cut(suffix = "€", right = FALSE) |>
table()
#>
#> Moins de 200.8€ 200.8 - 400.5€ 400.6 - 600.3€ 600.4 - 800.1€ Plus de 800.1€
#> 200 200 200 200 200