I want to name my bins 1:10 rather than them being called the interval of values within that bin.
df <- df %>% mutate(decile = cut(metric, breaks=10))
print(unique(df$decile))
10 Levels: (0.0821,0.274] (0.274,0.465] (0.465,0.655] (0.655,0.845] (0.845,1.04] (1.04,1.23] (1.23,1.42] (1.42,1.61] (1.61,1.8] (1.8,1.99]
I want the values in column "decile" to be 1 for (0.0821,0.274], 2 for (0.274,0.465], 3 for (0.465,0.655] etc. up to 10 for (1.8,1.99]
Can't use str_replace since it's not character, and changing to character is not straightforward because of the ] sign, thinking there must be a simpler way?
Thank you