you need the function merge()
here is an example:
data1<-data.frame(a=letters[1:3],b=1:3)
data1<-data.frame(a=letters[2:4],b=4:6)
merge(data1,data2,by='letter') ## this shows only the intersection between two data
merge(data1,data2,by='letter',all.x=TRUE) ##this shows all the certain column in data1
merge(data1,data2,by='letter',all.y=TRUE) ##this shows all the certain column in data2
Also, if data1 and data 2 do not have the same column name like 'letter' you can try by.x by.y
More information,try ?merge
|