[R] compare 2 vectors

2007-06-28 Thread João Fadista
Dear all, I would like to take out the values from one vector that are equal to the values in another vector. Example: a - c(1,2,3,4,5,6,7,8,9) b - c(3,10,20,5,6) b_noRepeats = c(10,20) So I would like to have the vector b without the same values as vector a. Kind regards, João Fadista

Re: [R] compare 2 vectors

2007-06-28 Thread Christophe Pallier
On 6/28/07, João Fadista [EMAIL PROTECTED] wrote: I would like to take out the values from one vector that are equal to the values in another vector. Example: a - c(1,2,3,4,5,6,7,8,9) b - c(3,10,20,5,6) b_noRepeats = c(10,20) b[!(b %in% intersect(a,b))] See ?intersect -- Christophe

Re: [R] compare 2 vectors

2007-06-28 Thread Antonio, Fabio Di Narzo
setdiff(b, a) 2007/6/28, João Fadista [EMAIL PROTECTED]: Dear all, I would like to take out the values from one vector that are equal to the values in another vector. Example: a - c(1,2,3,4,5,6,7,8,9) b - c(3,10,20,5,6) b_noRepeats = c(10,20) So I would like to have the vector b

Re: [R] compare 2 vectors

2007-06-28 Thread Christophe Pallier
setdiff(b,a) is even simpler. On 6/28/07, Christophe Pallier [EMAIL PROTECTED] wrote: On 6/28/07, João Fadista [EMAIL PROTECTED] wrote: I would like to take out the values from one vector that are equal to the values in another vector. Example: a - c(1,2,3,4,5,6,7,8,9) b -

Re: [R] compare 2 vectors

2007-06-28 Thread Dimitris Rizopoulos
://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: João Fadista [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, June 28, 2007 11:55 AM Subject: [R] compare 2 vectors Dear all, I would like to take out the values from

Re: [R] compare 2 vectors

2007-06-28 Thread Romain Francois
Christophe Pallier wrote: On 6/28/07, João Fadista [EMAIL PROTECTED] wrote: I would like to take out the values from one vector that are equal to the values in another vector. Example: a - c(1,2,3,4,5,6,7,8,9) b - c(3,10,20,5,6) b_noRepeats = c(10,20) b[!(b %in%

Re: [R] compare 2 vectors

2007-06-28 Thread Alberto Monteiro
Romain Francois wrote: There is also a pretty useful operator %w/o% in the help page of %in%. see : ?`%in%` a - c(1,2,3,4,5,6,7,8,9) b - c(3,10,20,5,6) b %w/o% a [1] 10 20 I don't like the example. It's not obvious, in the expression... x[!x %in% y] ... that this is the