Reputation: 1137
I have a continuous variable ranging from 0 to 1000+. However, I want to convert them into groups with the lowest value 0 as a single group.
x <- cut(x, breaks = c(0,50,100,200,500,1000)),
labels = c("0","1-50","51-100","101-199","200-499",
"500-999",">1000")
Using cut function has not been able to achieve this purpose. Is there anything that I'm missing?
Upvotes: 2
Views: 4708
Reputation: 8072
You've got some issues in your call to cut
breaks
that should be there, prematurely ending the call.This should work:
x <- cut(x, breaks = c(0,50,100,200,500,1000,max(x)),labels = c("0-50","51-100","101-199","200-499","500-999", "1000+"), include.lowest = TRUE)
Upvotes: 3