[R] question

Duncan Murdoch murdoch.duncan at gmail.com
Fri Aug 5 18:04:57 CEST 2011


On 05/08/2011 10:46 AM, Angel Valverde Portal wrote:
> Hi everybody,
>
> How can I transform a 0/1 matrix into a TRUE/FALSE matrix, and vice versa?

If A is your matrix, and you really want 0 to be TRUE (a little 
weird...), just use

A == 0

and you get a logical matrix. To go the other way, as.numeric will 
convert TRUE to 1 and FALSE to 0; if you don't want that, pre- or 
post-process.

Duncan Murdoch



More information about the R-help mailing list