Re: [R] how to change automatically 0=no and 1=yes

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Thu 16 Jun 2005 - 00:06:30 EST

try this:

dat <- data.frame(matrix(sample(0:1, 100 * 20, TRUE), 100, 20)) ############
dat[] <- lapply(dat, factor, levels = c(0, 1), labels = c("no", "yes"))
dat

I hope it helps.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


> Dear R-helpers,
> I have dataset (data.frame) like below,
> x1 x2 x3 x4 x5 x6 x7 x8 x9 ... x1200
> 0 0 0 1 1 0 0 1 1
> 1 0 0 1 1 0 0 1 1
> 0 1 0 1 1 0 0 1 1
> 1 1 0 1 1 0 0 1 1
> ...
> How can I change automatically 0=no and 1=yes.

>

> Thank you very much in advance.
> Kindly regards,
> Muhammad Subianto
>

> ______________________________________________
> R-help@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
>

R-help@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 Received on Thu Jun 16 00:14:26 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:42 EST