[R] Matrix of dummy variables from a factor

Charles H. Franklin chfrankl at wisc.edu
Tue Dec 6 21:02:44 CET 2005


What is a simple way to convert a factor into a matrix of dummy variables?

fm<-lm(y~f)

where f is a factor takes care of this in the estimation. I'd like to 
save the result of expanding f into a matrix for later use.

Thanks.

Charles

-- 


 Charles H. Franklin
 Professor, Political Science
 University of Wisconsin, Madison
 franklin at polisci.wisc.edu
 chfrankl at wisc.edu
 608-263-2022 (voice)
 608-265-2663 (fax)




More information about the R-help mailing list