0

I have two datasets, the Ids in the datasets are unordered and there are multiple values which are present in one dataset but not in the other dataset.

What I want at the end is csv file which contains the non-common Ids of both the dataset columns.

Dataset 1
Id Quant
1     a
2     b
3     c
4     d
5     e
6     f
7     g

Dataset 2
Id Quant2
6     d
4     a
5     f
2     e
1     a
3     b
pogibas
  • 25,773
  • 19
  • 74
  • 108
devCodePro
  • 77
  • 1
  • 2
  • 13

1 Answers1

3

You can use the dplyr package which has a anti_join function for precisely this task:

library(dplyr)
anti_join(dataset1, dataset2, by = "Id")

This will return all rows of dataset1 where there is no matching Id in dataset2. Similarly you can take a look at

 anti_join(dataset2, dataset1, by = "Id")
Cettt
  • 10,939
  • 7
  • 31
  • 53