Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do Left join in r [duplicate]

Tags:

r

I have two dataset one and two

dataset one

a     b  c
111   a  1
112   b  2 
113   c  3
114   d  4
115   e  5

dataset two

e    d   g
222  ss  11
111  ff  22
113  ww  33 
114  qq  44
234  dd  55
534  vv  66

I want to do a left join

Below is the code written in SQL but when i try it in SQLDF it showing as error

proc sql;
create table join1 as
select one.*, two.*
from  one left join two
on one.a = two.e;
quit;
like image 863
111111 Avatar asked Nov 29 '22 09:11

111111


1 Answers

With dplyr, we can use left_join

library(dplyr)
left_join(df2, df1, by = c("e"="a"))
like image 102
akrun Avatar answered Dec 15 '22 11:12

akrun