I have the following data, where I have calculated the tercile for each value in x:
dc <- data.frame(x = c(1, 2, 5, 6, 8, 9))
dc$tercile <- fabricatr::split_quantile(dc$x, 3)
x tercile
1 1
2 1
5 2
6 2
8 3
9 3
I want to reflect the ranges in x for each tercile. The desired output:
x tercile
1 period 1-2
2 period 1-2
5 period 5-6
6 period 5-6
8 period 8-9
9 period 8-9
A tidyverse solution is preferred. Thanks!
You can use
sprintf()orpaste()by groups oftercile.