[R] Refactor all factors in a data frame

Hilmar Berger hilmar.berger at imise.uni-leipzig.de
Tue Jun 5 18:55:16 CEST 2007


Hi,
thanks for all suggestions - I found a solution myself within 5 minutes, 
but your suggestions are surely more elegant / shorter.

Thanks again,
Hilmar



hadley wickham schrieb:
> Hi Hilmar,
> 
> What was wrong with my solution?  It's much simpler and shorter.
> 
> cat <- sapply(df, is.factor)
> df[cat] <- lapply(df[cat], factor)
> 
> Hadley
> 
> On 6/5/07, Hilmar Berger <hilmar.berger at imise.uni-leipzig.de> wrote:
> 

> 


-- 

Hilmar Berger
Studienkoordinator
Institut für medizinische Informatik, Statistik und Epidemiologie
Universität Leipzig
Härtelstr. 16-18
D-04107 Leipzig

Tel. +49 341 97 16 101
Fax. +49 341 97 16 109
email: hilmar.berger at imise.uni-leipzig.de



More information about the R-help mailing list