Skip to content

Instantly share code, notes, and snippets.

@aravindhebbali
Last active September 24, 2017 07:36
Show Gist options
  • Save aravindhebbali/3e31f13a4194a8f1003034aa7d70d5ee to your computer and use it in GitHub Desktop.
Save aravindhebbali/3e31f13a4194a8f1003034aa7d70d5ee to your computer and use it in GitHub Desktop.
Joining Tables with dplyr
# install
install.packages('dplyr')
install.packages('readr')
# library
library(dplyr)
library(readr)
# import order data
order <- readr::read_csv('https://raw.githubusercontent.com/rsquaredacademy/datasets/master/order.csv')
order
# import customer data
customer <- readr::read_csv('https://raw.githubusercontent.com/rsquaredacademy/datasets/master/customer.csv')
customer
# inner join
customer %>%
inner_join(order)
# left join
customer %>%
left_join(order)
# right join
customer %>%
right_join(order)
# semi join
customer %>%
semi_join(order)
# anti join
customer %>%
anti_join(order)
# full join
customer %>%
full_join(order)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment