Finally, we'll learn one more SQL-like function:
inner_join(). As you might have guessed, this works a lot like
INNER JOIN in SQL. There are other joins available in
dplyr, but we won't go into them here.
For those not familiar with SQL,
inner_join() takes two sets of data and joins their contents based on matching fields in a specific column. The arguments are the datasets being joined (like tables in SQL) and the column name that holds the matching data.
If we have data about countries' GDPs (gross domestic product) in the
countries dataset and want to join that data with the corresponding country names, we'd write:
countries <- inner_join(
by = "country_name")