Skip to content
Prev 167527 / 398502 Next

Compare matrices

Use the is.na() function to assign
NA values:
[,1] [,2] [,3]
[1,]    3   NA   NA
[2,]    3    3    3
[3,]    3    3   NA
[1] TRUE





Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada




-----Original Message-----
From: r-help-bounces at r-project.org on behalf of Dimitris Rizopoulos
Sent: Mon 1/19/2009 12:54 PM
To: Andrej Kastrin
Cc: r-help at r-project.org
Subject: Re: [R] Compare matrices
 
try this:

A <- matrix(c(3,3,3,3,3,3,3,3,3),3,3)
B <- matrix(c(T,T,T,F,T,T,F,T,F),3,3)

C <- A
C[!B] <- NA
C


I hope it helps.

Best,
Dimitris
Andrej Kastrin wrote: