Joining tables

Finally, there are a few helpful functions to merge tibble. Various types of joins are supportedfor example, inner_join, left_join, and right_join. The main difference among these is related to which rows are kept from two tibble in the event there is no match.

An example of left_join has been provided here for reference. More exhaustive treatment of these join types is available online:

astate <- tibble(Name=state.name, Abbr=state.abb) 
astate 
 
tstate %>% left_join(astate, by="Name") 

The output of the preceding code is as follows:

Note that the Abbr column has been added on the right.

Get Hands-On Data Science with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.