Hi,

Is it a requirement to provide the break intervals of the cut function in 
ascending order? The help documentation for cut didn't specify this but the 
labels returned are reversed if I indicate the break intervals in a descending 
order. Here is an example

tbl<-data.frame(x=c(0:10))
tbl$ascending<-cut(tbl$x, breaks=c(0,3,5,9,99), 
labels=c('<3','4-5','6-9','>9'), include.lowest=T)
tbl$descending<-cut(tbl$x, breaks=c(99,9,5,3,0), 
labels=c('>9','6-8','4-5','<3'), include.lowest=T)
tbl
    x ascending descending
1   0        <3        >9
2   1        <3        >9
3   2        <3        >9
4   3        <3        >9
5   4       4-5       6-8
6   5       4-5       6-8
7   6       6-9       4-5
8   7       6-9       4-5
9   8       6-9       4-5
10  9       6-9       4-5
11 10        >9        <3

Appreciate any guidance on this.
Regards
Wing Keong

                                          
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to