[R] breaks

Erin Hodgess hodgess at uhddx01.dt.uh.edu
Thu Jun 12 20:33:52 CEST 2003


Dear R People:

I have a question about a "sorting" problem, please.

I have a vector xx:

> xx

 [1] -2.0  1.4 -1.2 -2.2  0.4  1.5 -2.2  0.2 -0.4 -0.9

and a vector of breaks:

> xx.y

[1] -2.2000000 -0.9666667  0.2666667  1.5000000

I want to produce another vector z which contains the number of the class
that each data point is in.

for instance, xx[1] is between xx.y[1] and xx.y[2], so z[1] == 1

this can be accomplished via loops, but I was wondering if there is a more
efficient method, please.

By the way, eventually, there will be many more data points and more
classes.

thank you for any help!

sincerely,
Erin Hodgess
mailto: hodgesse at uhd.edu

Version 1.7.0 R for Windows




More information about the R-help mailing list