how i can merge two file with more than one condition in R?
0
0
Entering edit mode
13 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
R • 501 views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

What have you tried? Have you looked up the merge function in R (or the join family of functions in the dplyr package)? Please let us know what you've tried and where you run into difficulties and like ATPoint says, give us reproducible data.

ADD REPLY

Login before adding your answer.

Traffic: 2793 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