[R] Matrix of dummy variables from a factor

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Dec 6 22:05:51 CET 2005


Charles H. Franklin wrote:

> What is a simple way to convert a factor into a matrix of dummy variables?
> 
> fm<-lm(y~f)

  model.matrix(y~f)

Uwe Ligges

> 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
>




More information about the R-help mailing list