[R] dividing vectors into bins with equal widths
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.be
Tue Nov 14 14:16:58 CET 2006
you probably looking for something like:
x <- rnorm(20)
out <- cut(x, quantile(x, seq(0, 1, len = 11)), include.lowest = TRUE)
out
table(out)
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "W. Daniel Kissling" <kissling at uni-mainz.de>
To: <r-help at stat.math.ethz.ch>
Cc: <kissling at uni-mainz.de>
Sent: Tuesday, November 14, 2006 1:52 PM
Subject: [R] dividing vectors into bins with equal widths
Hi R-users,
I am trying to divide a vector (say X) into equal frequency bins. If
one uses the hist()
function, then a histogram is plotted, but with bins of equal widths,
and not with bins
having the same number of data points.
I have then tried the histogram() function as follows:
histogram(X, nint=10, breaks=NULL, equal.widths=F)
This works as I want. However, I can't extract which points are in
which bin, or where
the breakpoints are made.
Can anybody help?
Thanks
Daniel
--------------------------------------------------------------------
W. Daniel Kissling
Institut für Zoologie, Abteilung Ökologie
Johannes Gutenberg-Universität Mainz
D-55099 Mainz, Germany
E-mail: kissling at uni-mainz.de
______________________________________________
R-help at stat.math.ethz.ch 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.
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list