Learn R Programming

do (version 2.0.0.1)

join: Join two dataframes together

Description

Join two dataframes by the same id column.

Usage

join_inner(x, y, by = NULL)

join_full(x, y, by = NULL)

join_left(x, y, by = NULL)

join_right(x, y, by = NULL)

join_out(x, y, by = NULL)

Value

one joined dataframe.

Arguments

x

one dataframe

y

the other dataframe

by

the id name in x and y dataframe

Details

join_inner(), join_full(), join_left(), join_right() and join_out() are five functons to joint two dataframes together. They are based on package 'data.table', so they are more efficient and fast.

Examples

Run this code
df1=data.frame(x=rep(c('b','a','c'),each=3),
              y=c(1,3,6),
              v=1:9)

df2=data.frame(x=c('c','b','e'),
               v=8:6,
               foo=c(4,2,1))
join_inner(df1,df2,'x')
join_full(df1,df2,'x')
join_left(df1,df2,'x')
join_right(df1,df2,'x')
join_out(df1,df2,'x')

Run the code above in your browser using DataLab