On May 14, 2010, at 9:55 AM, 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

> findInterval(6, c(-Inf, brks) )
[1] 2


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

The first actually, but if you were considering the left hand boundary as -Inf, then you need to add it to the vector to get the correct answer from findInterval.


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.

David Winsemius, MD
West Hartford, CT

______________________________________________
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