Coding categorical -> dummy
Dear R-Users, I have a data frame with several categorical variables. I want to code these variables in dummy variables keeping all levels. I know the function model.matrix (see below) but it works only for one categorical variable :
tt <- c("a","a","b","a","c")
tt <- factor(tt)
model.matrix(~ tt - 1)
Is there anyone who have write such function ? Thanks for your help. Samir Messad Samir Messad E-Mail : messad at cirad.fr Statisticien CIRAD-EMVT TA 30/A Programme Productions Animales Campus de Baillarguet 34398 Montpellier cedex 5 (France) T?l : +33 (0)4-67-59-38-44 Fax : +33 (0)4-67-59-38-25 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._