Hello,
This should be a fairly simple question. I have 2 matrix's and I want to get
the difference between them and then remove the difference from one of them.
So A vs B, anything I see in B I want to remove from A, and then print out
the final matrix.
I have some code here but at the moment I'm getting stuck on the creating a
matrix, cbind problems.
clean <- function (A, B, rt=10, mass=0.01, pval=0.01){
i <-0
j <-0
d.A <-dim(A)
d.B <-dim(B)
clean <-0
for (i in i:d.A[1]){
for (j in j:d.B[1]){
if(any((A[i,6] - B[j,6]) <= mass)){
if (any((A[i,9] -
B[j,9])<rt)){
if (B[j,5]
>pval){
clean<-cbind(clean,A[i,])
}
}
}
}
}
return (clean)
}
I hope that I have explained myself well. If not please let me know and I'll
try to explain more.
Cheers,
PB
Research Technician
Mass Spectrometry
o The
/
o Scripps
\
o Research
/
o Institute
[[alternative HTML version deleted]]
Mark, A and B will probably be different sizes. Won't 'C<-A-B' just do the subtraction of matrix A by matrix B? So What I was thinking was that it would find 2 numbers one at position 6 and the other at position 9. If it finds roughtly these numbers in matrix B then it will identify this and remove that row from matrix A. Paul -----Original Message----- From: Leeds, Mark (IED) [mailto:Mark.Leeds at morganstanley.com] Sent: Wednesday, November 29, 2006 12:12 PM To: H. Paul Benton Subject: RE: [R] matrix comparison, and cbind issues. If A and B are the same size ( I can't tell ),then you can C<-A-B to get the dfiference but that might Be simplifying things too much. If it isn't simplifying thigns too, then let me know and I think I can show you how to do the rest. If it is, then my bad and I apologize.