[R] Problem with cut

2008-02-22 Thread Jussi.Lehto
Hi All, I might misunderstood how cut works. But following behaviour surprises me. vv - seq(150, 346, by= 4) cc - cut(vv, 12) cc[vv == 330] Results [1] (330,346] I would have expected 330 to fall into (313,330] category. Can you please advice what do I do wrong? Many Thanks, Jussi Lehto

Re: [R] Problem with cut

2008-02-22 Thread Henrique Dallazuanna
Try this: grep(330, levels(cc), value=T) On 22/02/2008, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi All, I might misunderstood how cut works. But following behaviour surprises me. vv - seq(150, 346, by= 4) cc - cut(vv, 12) cc[vv == 330] Results [1] (330,346] I would have

Re: [R] Problem with cut

2008-02-22 Thread Heinz Tuechler
At 15:22 22.02.2008, Henrique Dallazuanna wrote: Try this: grep(330, levels(cc), value=T) Could you please explain in a little more detail, how this answers the original question? I would have expected 330 to fall into (313,330] category. Can you please advice what do I do wrong? Thank you

Re: [R] Problem with cut

2008-02-22 Thread Henrique Dallazuanna
Is to show the categorys which contains '330' On 22/02/2008, Heinz Tuechler [EMAIL PROTECTED] wrote: At 15:22 22.02.2008, Henrique Dallazuanna wrote: Try this: grep(330, levels(cc), value=T) Could you please explain in a little more detail, how this answers the original question? I

Re: [R] Problem with cut

2008-02-22 Thread jim holtman
One way of finding out is to look at the code for cut.default. Here is the result of tracing through it where it determines where the cuts are for 12 equal spacings: D(2) [1] 149.804 166.170 182.536 198.902 215.268 231.634 248.000 264.366 280.732 297.098 313.464 329.830 [13] 346.196 As you can

Re: [R] Problem with cut

2008-02-22 Thread jim holtman
You can also get more detail on where the intervals are with 'dig.lab': cc - cut(vv, 12, dig.lab=6) str(cc) Factor w/ 12 levels (149.804,166.17],..: 1 1 1 1 1 2 2 2 2 3 ... cc [1] (149.804,166.17] (149.804,166.17] (149.804,166.17] (149.804,166.17] (149.804,166.17] [6] (166.17,182.536]