Hi, I'm looking for a function which divides a vector into n classes and returns the breaks as well as the number of values in each class. This is actually what hist(vector, breaks=n) does, but in hist() n is a suggestion only, and is a suggestion only and cannot be enforced (as far as I know...) It is not so difficult to do it yourself, but a ready made function would be nice... cheers wouter
see: ?cut ?findInterval wouter at paramo.be a ?crit :>Hi, > >I'm looking for a function which divides a vector into n classes and >returns the breaks as well as the number of values in each class. > >This is actually what hist(vector, breaks=n) does, but in hist() n is a >suggestion only, and is a suggestion only and cannot be enforced (as >far as I know...) > >It is not so difficult to do it yourself, but a ready made function would >be nice... > >cheers >wouter > >______________________________________________ >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 > > >
probably you're looking for ?cut(). 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://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: <wouter at paramo.be> To: <r-help at stat.math.ethz.ch> Sent: Monday, March 06, 2006 3:06 PM Subject: [R] break a vector into classes> > Hi, > > I'm looking for a function which divides a vector into n classes and > returns the breaks as well as the number of values in each class. > > This is actually what hist(vector, breaks=n) does, but in hist() n > is a > suggestion only, and is a suggestion only and cannot be enforced (as > far as I know...) > > It is not so difficult to do it yourself, but a ready made function > would > be nice... > > cheers > wouter > > ______________________________________________ > 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 >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Would a combination of cut() and range() and possibly seq() do what you need? Sean On 3/6/06 9:06 AM, "wouter at paramo.be" <wouter at paramo.be> wrote:> > Hi, > > I'm looking for a function which divides a vector into n classes and > returns the breaks as well as the number of values in each class. > > This is actually what hist(vector, breaks=n) does, but in hist() n is a > suggestion only, and is a suggestion only and cannot be enforced (as > far as I know...) > > It is not so difficult to do it yourself, but a ready made function would > be nice... > > cheers > wouter > > ______________________________________________ > 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