Questions tagged [set-difference]

The difference between two sets A and B consists of all elements that are in A but not in B.

Set difference is a mathematical operation defined on sets. It is also known as the relative complement of B with respect to A.
If we have two sets, say A and B, their difference A - B is the set of all elements that are in A but not in B.

Several programming languages have built-in features to remove a collection of elements from another collection of elements. When both collections are sets (meaning each element can occur at most once per collection and the order does not matter), this implements set difference.

Source: Wikipedia

197 questions
-2
votes
2 answers

setdiff in r is not pulling subset of data

I have two data frames: raw2 which has 28,406 records and raw3 26,421 records. The records in raw3 are a subset of those in raw2. In fact raw3 was derived using: raw3<-setDT(raw2)[order(O_ID, Program_forsorting), head(.SD, 1), .(O_ID)] I now have…
Danny
  • 554
  • 1
  • 6
  • 17
-8
votes
2 answers

Is there any possibility that the size of the vector is 1 but with zero number of elements in it?

Here in the below code i have 4 vectors a,b,v1,v2. After calculating set difference of a and b, b and a I have stored the reuslts of them in v1 and v2 vectors respectively. vector 'a' has the elements {'a','b','c'} and vector 'b' has the elements…
1 2 3
13
14