Re: [R] Conditional Matrices

From: Patrick Burns <pburns_at_pburns.seanet.com>
Date: Tue 16 Aug 2005 - 18:15:44 EST

ifelse(mat1, mat2, NA)

should do what you want.

Patrick Burns
patrick@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

ISAIAH SHALWITZ wrote:

>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).
>
>Please help.
>
>I
>
>______________________________________________
>R-help@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
>
>
>
>
>



R-help@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 Received on Tue Aug 16 18:20:08 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:22:20 EST