[R] Ordinal categorical data with GLM

John Fox jfox at mcmaster.ca
Tue Oct 8 14:42:50 CEST 2002


Dear Kenneth,

At 05:50 AM 10/8/2002 -0500, Kenneth Cabrera wrote:

>Is there an easy way (one line command, or at least without "for") to make a
>categorization of a continuos variable that I have in a vector, say "x", 
>and the
>limits of the categories in other vector, say "y". The vector "x" is 10000 
>length
>and the "y" vector is 101 length for 100 categories, where rank of "x" is 
>narrow
>or at least the same than the rank of "y".

         cut(x, breaks=y)

or, if you want an ordered factor,

         ordered(cut(x, breaks=y))

Be careful to set the first entry of breaks below min(x). See ?cuts for 
details.

I hope that this helps,
  John

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list