Re: [R] mask a matrix

From: Mwalili, S. M. <>
Date: Sat 11 Jun 2005 - 06:26:57 EST

This example could help:  

A <- matrix(rbinom(20,1,.8),ncol=2)
B <- cbind(rnorm(20,-1,0),rnorm(20,1,0))
B <- ifelse(A==0,NA,B)


S M Mwalili.

Lei Jiang <> wrote: Hi, there.

I have two matrix with identical dimentions. matrix A contains information of 0 and 1, and matrix B contains data. I only want the data in matrix B where matrix A has 1's. the places where matrix A has 0's, I want NA's in matrix B.

How do I do that??

Thank you very much.

Lei Jiang

Department of Chemsitry
University of Washington
Box 351700
Seattle, WA 98195
Phone: 206-616-6882
Fax: 206-685-8665 mailing list PLEASE do read the posting guide!                 

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide! Received on Sat Jun 11 06:31:48 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:31 EST