Member-only story

Get Started Using Anti-joins in R

What is an anti-join & how do I use it?

Rob W
Towards Data Science
3 min readJun 27, 2020

--

Image by Free-Photos from Pixabay

Introduction

Assuming you already have some background with the other more common types of joins, inner, left, right, and outer; adding semi and anti can prove incredibly useful saving you what could have alternatively taken multiple steps.

In a previous post, I outlined the benefits of semi-joins and how to use them. Here I’ll be following that up with a very similar explanation of anti-joins.

If you want to brush up on semi-joins first you can find that here.

Filtering Joins

Anti-joins & semi-joins are quite a bit different than the other four that I just highlighted; the number one difference being they are actually classified as what’s known as filtering joins.

Syntactically it feels very similar to any other join, but the intention is not to enhance a dataset with additional columns or rows, the intent is to use these joins to perform filtering.

A filtering join is not classified by the addition of new columns of information, rather it facilitates one being able to keep or reduce records in a given dataset.

The Anti-join

--

--

Towards Data Science
Towards Data Science

Published in Towards Data Science

Your home for data science and AI. The world’s leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

Rob W
Rob W

Written by Rob W

I’m a Data Science Leader sharing lessons learned & tips of the trade! Twitter: @data_lessons

No responses yet