Re: [R] Matching pairs of values

2010-03-28 Thread Bert Gunter
Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Scott Sent: Saturday, March 27, 2010 8:36 PM To: Peter Ehlers Cc: r-help@r-project.org; Berend Hasselman Subject: Re: [R] Matching pairs of values Many thanks Peter and Berend. I think I can

[R] Matching pairs of values

2010-03-27 Thread David Scott
I am sure someone can come up with a clever way of doing what I want---I don't seem to be able to. I want to check if a pair of numbers occurs as one of the rows of an n by 2 matrix. If I was only checking whether a single number was in a vector of numbers I would use %in% but I can't see how

Re: [R] Matching pairs of values

2010-03-27 Thread Berend Hasselman
David Scott-6 wrote: I am sure someone can come up with a clever way of doing what I want---I don't seem to be able to. I want to check if a pair of numbers occurs as one of the rows of an n by 2 matrix. If I was only checking whether a single number was in a vector of numbers I

Re: [R] Matching pairs of values

2010-03-27 Thread Peter Ehlers
On 2010-03-27 2:46, Berend Hasselman wrote: David Scott-6 wrote: I am sure someone can come up with a clever way of doing what I want---I don't seem to be able to. I want to check if a pair of numbers occurs as one of the rows of an n by 2 matrix. If I was only checking whether a single

Re: [R] Matching pairs of values

2010-03-27 Thread Peter Ehlers
(Sorry, I think that I just hit a wrong button and managed to send a non-reply.) I think that David might have meant that the column order of the numbers in lookfor is unimportant. In that case, a simple fix would be either to check both lookfor and rev(lookfor) (since the matrix is nX2) or to

Re: [R] Matching pairs of values

2010-03-27 Thread Berend Hasselman
Peter Ehlers wrote: I think that David might have meant that the column order of the numbers in lookfor is unimportant. In that case, a simple fix would be either to check both lookfor and rev(lookfor) (since the matrix is nX2) or to sort before testing: vtest - function(x, lookfor){

Re: [R] Matching pairs of values

2010-03-27 Thread David Scott
Many thanks Peter and Berend. I think I can make this work for my problem. Apologies for not giving an example: I was a bit tired and frustrated when I posted to R-help and only on later reflection realised that I didn't really follow the posting guidelines. David Peter Ehlers wrote: