I'm newer to R, so this may be a silly mistake. I'm trying to use the cut function, but I keep getting the same error. Error is:
Error: Problem with `mutate()` input `Calls_bucket`.
x 'breaks' are not unique
i Input `Calls_bucket` is `cut(...)
Here's my code (I've tried many different variations. Here are two most recent):
m3 <- m2 %>%
mutate(Calls_bucket=cut(Calls_per_Hour,c(2,4,6,8,10,12,14,16,18,20,max(Calls_per_Hour, na.rm=T)),
labels=c("0-2","2-4","4-6","6-8","8-10","10-12","12-14","14-16","16-18","18-20",">20")))
m3 <- m2 %>%
mutate(Calls_bucket=cut(Calls_per_Hour,breaks=c(2,4,6,8,10,12,14,16,18,20,max(Calls_per_Hour, na.rm=T)),labels=c("0-2","2-4","4-6","6-8","8-10","10-12","12-14","14-16","16-18","18-20",">20")))
I can get it to work if I simply pick the number of breaks, but I want to define them specifically. this code works, for example:
m3 <- m2 %>%
mutate(Calls_bucket=cut(Calls_per_Hour,12))
thanks in advance. any help would be greatly appreciated.