merge two dataframes
2
0
Entering edit mode
@ghislaine-guigon-749
Last seen 10.2 years ago
Hi, I would try to merge 2 dataframes x1, x2 with same structure. ID is the common columns. I don't understand why the result, x, is composed of NA ? Is someone understand the problem ? The code is : > x2[1:3,] ID sVOL logSignalMean 4340 8559;27*L11 3189.818 11.6392584 4335 8547;27*L9 3419.657 11.7396359 3267 6441;27*I18 0.000 -0.4460873 > x1[1:3,] ID sVOL logSignalMean 4339 8557;25*L11 2972.267 11.5373480 4334 8545;25*L9 3380.747 11.7231263 3266 6439;25*I18 0.000 -0.4460873 > x<- merge(x1,x2,by.x=ID,by.y=ID,suffixes=c("1","2")) > x[1:3,] ID sVOL1 logSignalMean1 sVOL2 logSignalMean2 NA <na> NA NA NA NA NA.1 <na> NA NA NA NA NA.2 <na> NA NA NA NA thanks, gg
• 1.0k views
ADD COMMENT
0
Entering edit mode
@sean-davis-490
Last seen 3 months ago
United States
On Tuesday 13 February 2007 04:29, Ghislaine Guigon wrote: > Hi, > > I would try to merge 2 dataframes x1, x2 with same structure. ID is the > common columns. I don't understand why the result, x, is composed of NA ? > Is someone understand the problem ? > > The code is : > > x2[1:3,] > > ID sVOL logSignalMean > 4340 8559;27*L11 3189.818 11.6392584 > 4335 8547;27*L9 3419.657 11.7396359 > 3267 6441;27*I18 0.000 -0.4460873 > > > x1[1:3,] > > ID sVOL logSignalMean > 4339 8557;25*L11 2972.267 11.5373480 > 4334 8545;25*L9 3380.747 11.7231263 > 3266 6439;25*I18 0.000 -0.4460873 > > > x<- merge(x1,x2,by.x=ID,by.y=ID,suffixes=c("1","2")) The by argument needs to be a number, a logical vector, or character. You are supplying a variable which is being interpreted as one of these. Change the statement to: x<- merge(x1,x2,by.x="ID",by.y="ID",suffixes=c("1","2")) That will probably get you the answer you want. > > x[1:3,] > > ID sVOL1 logSignalMean1 sVOL2 logSignalMean2 > NA <na> NA NA NA NA > NA.1 <na> NA NA NA NA > NA.2 <na> NA NA NA NA > > thanks, > gg
ADD COMMENT
0
Entering edit mode
alex lam RI ▴ 310
@alex-lam-ri-1491
Last seen 10.2 years ago
Hi Ghislaine, Try x<- merge(x1,x2,by.x="ID",by.y="ID",suffixes=c("1","2"),all.x=TRUE,all.y=T RU E) Thanks, Alex ------------------------------------ Alex Lam PhD student Department of Genetics and Genomics Roslin Institute (Edinburgh) Roslin Midlothian EH25 9PS Great Britain Phone +44 131 5274471 Web http://www.roslin.ac.uk Roslin Institute is a company limited by guarantee, registered in Scotland (registered number SC157100) and a Scottish Charity (registered number SC023592). Our registered office is at Roslin, Midlothian, EH25 9PS. VAT registration number 847380013. The information contained in this e-mail (including any attachments) is confidential and is intended for the use of the addressee only. The opinions expressed within this e-mail (including any attachments) are the opinions of the sender and do not necessarily constitute those of Roslin Institute (Edinburgh) ("the Institute") unless specifically stated by a sender who is duly authorised to do so on behalf of the Institute -----Original Message----- From: bioconductor-bounces@stat.math.ethz.ch [mailto:bioconductor-bounces at stat.math.ethz.ch] On Behalf Of Ghislaine Guigon Sent: 13 February 2007 09:30 To: bioconductor at stat.math.ethz.ch Subject: [BioC] merge two dataframes Hi, I would try to merge 2 dataframes x1, x2 with same structure. ID is the common columns. I don't understand why the result, x, is composed of NA ? Is someone understand the problem ? The code is : > x2[1:3,] ID sVOL logSignalMean 4340 8559;27*L11 3189.818 11.6392584 4335 8547;27*L9 3419.657 11.7396359 3267 6441;27*I18 0.000 -0.4460873 > x1[1:3,] ID sVOL logSignalMean 4339 8557;25*L11 2972.267 11.5373480 4334 8545;25*L9 3380.747 11.7231263 3266 6439;25*I18 0.000 -0.4460873 > x<- merge(x1,x2,by.x=ID,by.y=ID,suffixes=c("1","2")) > x[1:3,] ID sVOL1 logSignalMean1 sVOL2 logSignalMean2 NA <na> NA NA NA NA NA.1 <na> NA NA NA NA NA.2 <na> NA NA NA NA thanks, gg
ADD COMMENT

Login before adding your answer.

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