Andrei -
Looking inside the code for cut, it looks like you could retrieve the breaks as follows:
getbreaks = function(x,nbreaks){
    nb = nbreaks + 1
    dx = diff(rx <- range(x,na.rm=TRUE))
    seq.int(rx[1] - dx/1000,rx[2] + dx/1000,length.out=nb)
}

The dx/1000 is what makes cut()'s break different than
a simple call to seq().


                                        - Phil Spector
                                         Statistical Computing Facility
                                         Department of Statistics
                                         UC Berkeley
                                         spec...@stat.berkeley.edu



On Fri, 15 Oct 2010, Andrei Zorine wrote:

Hello,
My question is assuming I have cut()'ed my sample and look at the
table() of it, how can I compute probabilities for the bins? Do I have
to parse table's names() to fetch bin endpoints to pass them to
p[distr-name] functions? i really don't want to input arguments to PDF
functions by hand (nor copy-and-paste way).

x.fr <- table(cut(x,10))
x.fr
(0.0617,0.549]   (0.549,1.04]    (1.04,1.52]    (1.52,2.01]     (2.01,2.5]
          16             28             26             18              6
  (2.5,2.99]    (2.99,3.48]    (3.48,3.96]    (3.96,4.45]    (4.45,4.94]
           3              2              0              0              1

names(x.fr)
[1] "(0.0617,0.549]" "(0.549,1.04]"   "(1.04,1.52]"    "(1.52,2.01]"
[5] "(2.01,2.5]"     "(2.5,2.99]"     "(2.99,3.48]"    "(3.48,3.96]"
[9] "(3.96,4.45]"    "(4.45,4.94]"


--

Andrei Zorine

______________________________________________
R-help@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.

______________________________________________
R-help@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.

Reply via email to