Entering edit mode
20 months ago
sata72
•
0
I want to merge two file if col1 and col2 in two file be the same:
Input:
file1:
col1 col2 col3 col4 col5 col6
1 1355 1355 83.33 10 2
1 1357 1357 70 12 4
2 1359 1359 80 12 3
3 1355 1355 70 14 5
...
file2:
col1 col2 col3 col4 col5 col6 col7
1 1355 + 5 0 GG GGA
...
Output:
All columns of file 1 and col3, col6 and col7 from file 2:
col1 col2 col3 col4 col5 col6 col 7 col8 col9
1 1355 1355 83.33 10 2 + GG GGA
It's bad practice to post a question like this. First, there is no effort since you do not show what you tried, and second it requires users to manually type down the example data. Use
dput()
and use its output to share example data. Please do that now.What have you tried? Have you looked up the
merge
function in R (or thejoin
family of functions in thedplyr
package)? Please let us know what you've tried and where you run into difficulties and like ATPoint says, give us reproducible data.