[R] how to change automatically 0=no and 1=yes
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.be
Wed Jun 15 16:06:30 CEST 2005
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
----- Original Message -----
From: "Muhammad Subianto" <subianto at gmail.com>
To: <R-help at stat.math.ethz.ch>
Sent: Wednesday, June 15, 2005 3:58 PM
Subject: [R] how to change automatically 0=no and 1=yes
> 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 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
>
More information about the R-help
mailing list