Question: Merging data coloum wise in R
0
gravatar for David_emir
4 days ago by
David_emir210
India
David_emir210 wrote:

Hello All,

I am using R to merge two different CSV file into one new file. both of them has got gene name (1st column) same and the subsequent columns will be my sample ID, I need the output file as follow'

1st_file.csv

Gene    sample1 sample2 smpleN
a   1   4   7
b   2   5   8
c   3   6   9

2nd_file.csv

Gene    sample3 sample4 smpleN1
a   1   4   7
b   2   5   8
c   3   6   9

I need to have a combined file a

Gene    sample1 sample2 smpleN  sample3 sample4 smpleN1
a   1   4   7   1   4   7
b   2   5   8   2   5   8
c   3   6   9   3   6   9

Please let me know how to get this in R

csv R • 133 views
ADD COMMENTlink modified 4 days ago by biplab40 • written 4 days ago by David_emir210
2

What have you tried? You can generally google for things like this.

ADD REPLYlink written 4 days ago by Devon Ryan74k

Run ?cbind and look at the examples.

ADD REPLYlink written 4 days ago by Alex Reynolds22k
2
gravatar for biplab
4 days ago by
biplab40
University of California, Davis
biplab40 wrote:

Read both files in R. Then use: merge(file1, file2, by='Gene', all=TRUE)

ADD COMMENTlink written 4 days ago by biplab40
0
gravatar for pfs
4 days ago by
pfs200
USA/Boston
pfs200 wrote:

Look into the merge command.

ADD COMMENTlink written 4 days ago by pfs200
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1402 users visited in the last hour