Re: [R] Refactor all factors in a data frame

From: Hilmar Berger <hilmar.berger_at_imise.uni-leipzig.de>
Date: Tue, 05 Jun 2007 18:55:16 +0200

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

______________________________________________
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.
Received on Tue 05 Jun 2007 - 17:00:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Jun 2007 - 17:31:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.