how to substract numbers from levels

Posted by romunov on Stack Overflow See other posts from Stack Overflow or by romunov
Published on 2010-06-09T07:57:12Z Indexed on 2010/06/09 9:02 UTC
Read the original article Hit count: 285

Filed under:
|
|

Dear SOFers,

I would like to cut a vector of values ranging 0-70 to x number of categories, and would like the upper limit of each category. So far, I have tried this using cut() and am trying to extract the limits from levels. I have a list of levels, from which I would like to extract the second number from each level. How can I extract the values between space and ] (which is the number I'm interested in)?

I have:

> levels(bins)
 [1] "(-0.07,6.94]" "(6.94,14]"    "(14,21]"      "(21,28]"      "(28,35]"     
 [6] "(35,42]"      "(42,49]"      "(49,56]"      "(56,63.1]"    "(63.1,70.1]" 

and would like to get:

[1] 6.94 14 21 28 35 42 49 56 63.1 70.1

Or is there a better way of calculating the upper bounds of categories?

© Stack Overflow or respective owner

Related posts about r

    Related posts about grep