[R] Coding categorical variables in mixed environment

John Kane jrkrideau at yahoo.ca
Sun Jun 10 12:26:59 CEST 2007


try ?recode in package:car

--- spime <sabya23 at gmail.com> wrote:

> 
> Hi R users,
> 
> Suppose we have following data for a regression
> model:
> 
> AGE:numerical
> SEX: male/female categorical
> COLOR: {blue, green, pink} categorical
> RESPONSE: yes/no categorical
> 
> AGE      SEX      COLOR      RESPONSE
> 10         M          BLUE         Y
> 12         M          GREEN       N
> 13         F           PINK         Y
> 11         M          BLUE         Y
> 13         M          GREEN       N
> 09         F           GREEN       N
> 15         F           BLUE         Y
> 11         F           PINK          Y
> 12         M          PINK          N
> 14         M          GREEN        N
> 
> I want to code the categorical data as {male =1,
> female =2}, {blue =1, green
> =2, pink = 3} {yes =1, no =0} and finally get the
> new table.
> 
> how can i do this?
> 
> waiting for reply. Thanks in advance.
> 
> bye
> 
>  
> -- 
> View this message in context:
>
http://www.nabble.com/Coding-categorical-variables-in-mixed-environment-tf3896721.html#a11046822
> Sent from the R help mailing list archive at
> Nabble.com.
> 
> ______________________________________________
> 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.
>



More information about the R-help mailing list