[R] feed cut() output into goodness-of-fit tests

Andrei Zorine zoav1602 at gmail.com
Fri Oct 15 16:22:17 CEST 2010


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



More information about the R-help mailing list