> x<- rnorm(200)
> hist(x, 18)
> str(hist(x, 18))
List of 7
 $ breaks     : num [1:15] -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 ...
 $ counts     : int [1:14] 3 1 8 12 34 35 40 30 18 11 ...
 $ intensities: num [1:14] 0.03 0.01 0.08 0.12 0.34 ...
 $ density    : num [1:14] 0.03 0.01 0.08 0.12 0.34 ...
$ mids : num [1:14] -2.75 -2.25 -1.75 -1.25 -0.75 -0.25 0.25 0.75 1.25 1.75 ...
 $ xname      : chr "x"
 $ equidist   : logi TRUE
 - attr(*, "class")= chr "histogram"
> hist(x, 18, plot=FALSE)$breaks
[1] -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0


At 09:55 AM 5/14/2010, Research wrote:
Hello,

Is there a function that returns the number of the "bin" (or quantile, or percentile etc. etc.) that a value of a variable may belong to?

Tor example:

breaks<-hist(variable, 18, plot=FALSE)

If the following breaks are

 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85

the boundaries of successive bins of a histogram, then value "6" belongs to the 2nd bin.

Best regards,
Costas

______________________________________________
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.

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: r...@lcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"

______________________________________________
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