Merge two tables based on two columns (R)
1
0
Entering edit mode
5.4 years ago
lessismore ★ 1.4k

Dear all,

trivial question. i have two tables that i would like to merge based on two columns. Basically i would like to translate to R what here i write in bash.

1st table (file a)

a   Solyc11g071810
a   Solyc11g071811
a   Solyc11g071812
a   Solyc11g071813
a   Solyc11g071814

2nd table (file b)

a   Solyc11g071810  low
a   Solyc11g071811  high
a   Solyc11g071812  medium
a   Solyc11g071813  very low
a   Solyc11g071814  medium
a   Solyc11g071819  very low
b   Solyc11g071813  high

Expected result (file c):

a   Solyc11g071810  low
a   Solyc11g071811  high
a   Solyc11g071812  medium
a   Solyc11g071813  very low
a   Solyc11g071814  medium

bash code:

cat a  | grep -w -F -f - b > c

thanks in advance for any help

R • 1.0k views
ADD COMMENT
3
Entering edit mode
5.4 years ago
Ram 44k

Please search online and do some homework before you ask us to help you. See the first result when you google "r merge by two columns".

You can use by = c('col1','col2') in merge to get to your result.

ADD COMMENT

Login before adding your answer.

Traffic: 1778 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6