In R, joins (e.g., left_join) auto-detect matching columns, although you can optionally indicate what to join on, and you can also specify if the column names that needed to be joined on have different names.
In the first pass, I would like to implement this capability in a series of macros, where of the following is valid:
@left_join(df1, df2) # columns to join on are inferred based on matching names
@left_join(df1, df2, by = id) # match on id column
@left_join(df1, df2, by = join_by(id)) # match on id column
@left_join(df1, df2, by = join_by(id1 == id2)) # match id1 in df1 to id2 in df2
These last 2 examples are based on the new join_by syntax in the newest dplyr, with the eventual hope that we will support non-equijoins using this similar syntax.
In R, joins (e.g.,
left_join
) auto-detect matching columns, although you can optionally indicate what to join on, and you can also specify if the column names that needed to be joined on have different names.In the first pass, I would like to implement this capability in a series of macros, where of the following is valid:
@left_join(df1, df2) # columns to join on are inferred based on matching names
@left_join(df1, df2, by = id) # match on id column
@left_join(df1, df2, by = join_by(id)) # match on id column
@left_join(df1, df2, by = join_by(id1 == id2)) # match id1 in df1 to id2 in df2
These last 2 examples are based on the new
join_by
syntax in the newestdplyr
, with the eventual hope that we will support non-equijoins using this similar syntax.