Hi all,

Suppose I have a matrix of logical value:

x<-matrix(c(TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE),nrow=3)

I would like to change the value of FALSE to 0 and TRUE to 1. An
obvious way to do it is :
y<-as.numeric(x)

However this method doesn't keep the dim of x. I also need to copy the
dim information to y too.
attributes(y)<-attributes(x)

Is this a correct way to do it in R? Is there any single step function
which can do the something? Thanks


Regards,
TszKin Julian

______________________________________________
R-help@r-project.org 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.

Reply via email to