Re: [R] change cell values

2013-07-03 Thread arun
mat2 # [,1] [,2] [,3] [,4] #[1,]   NA   NA   NA 1.841481 #[2,]   NA   NA   NA   NA #[3,]   NA   NA   NA 1.520367 A.K. - Original Message - From: JiangZhengyu To: "r-help@r-project.org" Cc: Sent: Wednesday, July 3, 2013 5:27 PM Subject: [R] change cell values

Re: [R] change cell values

2013-07-03 Thread David Winsemius
On Jul 3, 2013, at 2:27 PM, JiangZhengyu wrote: > > > > Dear R experts, > > I have two matrices (mat1 & mat2) with the same dimension & the cells (row > and column) are corresponding to each other. > > I want to change cell values to NA given values of the corresponding cells in > mat1 an

Re: [R] change cell values

2013-07-03 Thread JiangZhengyu
Hi Rui, Yes, I see. You are right. Thanks for your help. Zhengyu > Date: Wed, 3 Jul 2013 22:38:37 +0100 > From: ruipbarra...@sapo.pt > To: zhyjiang2...@hotmail.com > CC: r-help@r-project.org > Subject: Re: [R] change cell values > > Hello, > > It's not

Re: [R] change cell values

2013-07-03 Thread Rui Barradas
Hello, It's not working because you are changing mat1 before the second condition is evaluated, and so mat1 is full of NA values. Try the following. tmp <- mat1 # Make a copy tmp[mat1 < 1 & mat2 < 1] <- NA # And change that copy mat2[mat1 < 1 & mat2 < 1] <- NA mat1 <- tmp rm(tmp) Hope th

[R] change cell values

2013-07-03 Thread JiangZhengyu
Dear R experts, I have two matrices (mat1 & mat2) with the same dimension & the cells (row and column) are corresponding to each other. I want to change cell values to NA given values of the corresponding cells in mat1 and mat2 are both <1. E.g. both mat1[2,3] and mat2[2,3] are <1, I wil