# Re: [R] Conditional Matrices

From: Ales Ziberna <aleszib_at_gmail.com>
Date: Tue 16 Aug 2005 - 18:34:42 EST

#M1 = first matrix
#M2 = second matrix

M2[M1==0]<-NA

• Original Message ----- From: "ISAIAH SHALWITZ" <shalwitz.1@osu.edu> To: <r-help@stat.math.ethz.ch> Sent: Tuesday, August 16, 2005 5:00 AM Subject: [R] Conditional Matrices

> This seems like a simple problem but I can't figure it out:
>
> I have two identical DIMENSION matrices. Both contain only binary values
> NOT identical between matrices. What I want to do: If in cell (1,1) the
> value in the first matrix (x) equals 1, then I keep the value in cell
> (1,1) in the second matrix (y). If in cell (1,1) the value in the first
> matrix (x) equals 0, then I change the value in cell (1,1) in the second
> matrix (y)to missing (NA). Repeat for every pair of cells (coordinates of
> the paired cells always match).
>
>
> I
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help