[R] table and colnames

jim holtman jholtman at gmail.com
Thu Sep 4 18:11:27 CEST 2008


Here is one way:

> y <- levels(cut(x,5))
> y
[1] "(0.0124,0.209]" "(0.209,0.405]"  "(0.405,0.601]"  "(0.601,0.797]"
 "(0.797,0.993]"
> sapply(y, function(x) sub(".*,(.*)]", "\\1", x))
(0.0124,0.209]  (0.209,0.405]  (0.405,0.601]  (0.601,0.797]  (0.797,0.993]
       "0.209"        "0.405"        "0.601"        "0.797"        "0.993"
> as.numeric(sapply(y, function(x) sub(".*,(.*)]", "\\1", x)))
[1] 0.209 0.405 0.601 0.797 0.993
>


On Thu, Sep 4, 2008 at 9:20 AM, Trubisz, Joseph
<jtrubisz at modernconsumer.com> wrote:
> I have a table statement that returns the following:
>
>
>
> [10.839,10.841] (10.841,10.843] (10.843,10.846] (10.846,10.848]
> (10.848,10.85]
>
>              0               0               0               0
> 1
>
>  (10.85,10.852] (10.852,10.854] (10.854,10.857] (10.857,10.859]
> (10.859,10.861]
>
>              0               0               0               0
> 0
>
>
>
> What I want to do is get the upper bound value into a vector for each of
> the 10-buckets.
>
> (e.g. v<-c(10.841,10.843...)
>
> I'm totally clueless on how to proceed.
>
> Any help appreciated.
>
>
>
> TIA,
>
> Joe
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list