[R] recoding variables

Spencer Graves spencer.graves at pdf.com
Thu Mar 11 16:26:42 CET 2004


(tst <- cut(1:11, c(-Inf, 3, 5, Inf)))
 [1] (-Inf,3] (-Inf,3] (-Inf,3] (3,5]    (3,5]    (5,Inf]  (5,Inf]  (5,Inf]
 [9] (5,Inf]  (5,Inf]  (5,Inf]
Levels: (-Inf,3] (3,5] (5,Inf]
 >
 > class(tst)
[1] "factor"

      hope this helps.  spencer graves

Shayna Strom wrote:

>Hi,
>
>I was hoping someone could help me.  I am a graduate student new to using R, and I'm trying to figure out how to recode a continuous variable to make it into an ordinal variable with 3 categories.  I literally have no idea how to proceed--could anyone possibly advise me?  Please copy me on any responses, as I have just subscribed to the R-help email list but don't know whether the subscription has gone through yet.
>
>Thanks so much-
>Shayna
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>




More information about the R-help mailing list