Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the R equivalent of the "except" function?

I have two datasets, df1 and df2, having the same number of columns and the same header. I want to remove all rows in df1 that are also present in df2. In SQL, I’d use the function except. df1 except df2.

What is the equivalent of except in R?

df1:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

cust_id
1
2
3

df2

cust_id
1
2

df1 except df2 would result in:

cust_id
3

>Solution :

You can use setdiff

df1 <- setdiff(df1, df2)

df1
#>   cust_id
#> 1       3
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading