[R] better define: matrix comparison and cbind issue
H. Paul Benton
hpbenton at scripps.edu
Thu Nov 30 02:42:43 CET 2006
Ok, so columns are fixed and my apologizes, for the incorrect subscripting.
So I have the matching down because I'm matching a number so I've used an if
statement with some fuzz. At the moment my code from my earlier post gets me
a long vector with the data in it but not a nice matrix that is readable.
Also this matrix is only the stuff which was found to be in both A and B. I
would like to get A - B as shown before.
Cheers,
Paul
PS. Thx to mark, but don't miss your deadline.
----------
Mark wrote:
I understand better now but I just have 1 question and 1 comment.
1) how do you know which columns to compare ? Is that fixed, like
parameters x an y where in the case below X = 1 and y = 1 ? Or does it
somehow depend on the matrix ?
2) your email was still really confusing because you are subscripting
incorrectly when you Refers to rows and columns. You have it backwards :
A[1,] is the first row.
A[,1] is the first column.
-----Original Message-----
From: jim holtman [mailto:jholtman at gmail.com]
Sent: Wednesday, November 29, 2006 2:40 PM
To: H. Paul Benton
Subject: Re: [R] better define: matrix comparison and cbind issue
match(a[9,], b[9,])
will tell you which elements in 'a' match 'b'
On 11/29/06, H. Paul Benton <hpbenton at scripps.edu> wrote:
> Hello,
>
> Sorry to all for the lack of communication, and thanks to those with the
> suggestions.
>
> So I have two matrixes which are different sizes, same column number but
> different row number.
>
> What I would like to do is to compare A to B. In the 6 and 9th column
there
> are ref numbers (molecular masses to be exact). I would like to check A
and
> B by these columns. If I find that the number in A[9,x] and B[9, x] are
the
> same then I want to remove the row that it is comparing from A. So
overall,
> if something appears in B then I remove it from A.
>
>
>
> Cheers,
>
>
>
> Paul
>
>
>
>
>
> Research Technician
>
> Mass Spectrometry
>
> o The
>
> /
>
> o Scripps
>
> \
>
> o Research
>
> /
>
> o Institute
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list