[R] how to change automatically 0=no and 1=yes
Muhammad Subianto
subianto at gmail.com
Wed Jun 15 18:07:06 CEST 2005
Dear all,
Sean Davis, Dimitris Rizopoulos and Marc Schwartz, thanks for your great
help. It works perfectly. Thanks a lot.
All the best,
Muhammad Subianto
On this day 6/15/2005 4:06 PM, Sean Davis wrote:
> > x <- data.frame(matrix(c(1,0,1,0,1,1),nrow=3))
> > x[x==0] <- 'no'
> > x[x==1] <- 'yes'
> > x
> X1 X2
> 1 yes no
> 2 no yes
> 3 yes yes
>
On this day 6/15/2005 4:06 PM, Dimitris Rizopoulos wrote:
> 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
>
On this day 6/15/2005 4:16 PM, Marc Schwartz wrote:
>
>
>>as.data.frame(ifelse(df == 0, "No", "Yes"))
>
On this day 6/15/2005 3:58 PM, Muhammad Subianto wrote:
> 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