[R] For help in R coding

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Tue Jul 5 16:53:41 CEST 2011


Dear Vikas,

Have at look at ?merge()

Best regards,

Thierry

> -----Oorspronkelijk bericht-----
> Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org]
> Namens Bansal, Vikas
> Verzonden: dinsdag 5 juli 2011 16:51
> Aan: David Winsemius
> CC: r-help op r-project.org
> Onderwerp: Re: [R] For help in R coding
> 
> Dear all,
> 
> I have one problem and did not find any solution.Please I want your help.
> 
> I have two data frames and I want to concatenate them.But the thing is-
> 
> two data frames are like this-
> 
> V1	       V2	        A	C	G	T
> 10	135344109	0	0	1	0
> 10	135344110	0	1	0	0
> 10	135344111	0	0	1	0
> 10	135344112	0	0	1	0
> 10	135344113	0	0	1	0
> 10	135344114	1	0	0	0
> 10	135344115	1	0	0	0
> 10	135344116	0	0	0	1
> 10	135344117	0	1	0	0
> 10	135344118	0	0	0	1
> 
> second data frame-
> 
> V1	       V2	        A	C	G	T
> 10	135344111	1	0	1	0
> 10	135344113	0	0	1	0
> 10	135344109	0	3	1	0
> 10	135344114	1	0	0	0
> 10	145344115	1	0	0	0
> 10	135344116	1	0	0	1
> 10	132344117	0	1	0	0
> 10	135344118	0	0	0	1
> 10	135344110	0	1	0	0
> 
> now i have to create a new data frame which has  insert column 3,4,5 and 6 of
> second data frame in first data frame if the value in second column is same in
> both the data frames (values in V2 column).So the output(new data frame)
> should be-
> 
> V1	       V2	        A	C	G	T     A       C     G      T
> 10	135344109	0	0	1	0      0	3	1	0
> 10	135344110	0	1	0	0      0	1	0	0
> 10	135344111	0	0	1	0      1	0	1	0
> 10	135344113	0	0	1	0      0	0	1	0
> 10	135344114	1	0	0	0      1	0	0	0
> 10	135344116	0	0	0	1      1	0	0	1
> 10	135344118	0	0	0	1      0	0	0	1
> 
> I f you see the output, second column values-
> 
> 	       V2
> 	135344109
> 	135344110
> 	135344111
> 	135344113
> 	135344114
> 	135344116
> 	135344118
> 
> these values are common in both input dataframes.
> 
> 
> 
> 
> 
> 
> Thanking you,
> Warm Regards
> Vikas Bansal
> Msc Bioinformatics
> Kings College London
> ________________________________________
> From: David Winsemius [dwinsemius op comcast.net]
> Sent: Monday, July 04, 2011 12:11 AM
> To: Bansal, Vikas
> Cc: Dennis Murphy; r-help op r-project.org
> Subject: Re: [R] For help in R coding
> 
> On Jul 3, 2011, at 6:10 PM, Bansal, Vikas wrote:
> 
> >
> > ________________________________________
> > From: David Winsemius [dwinsemius op comcast.net]
> > Sent: Sunday, July 03, 2011 7:08 PM
> 
> >>
> >
> > the code is same i just want to add a condition so that  it should
> > check that if in column 3, the character is A then make number of A
> > equal to total number of . and ,
> >
> > Should I explain better or can you please tell me which thing is not
> > clear?
> 
> My second posting today had a solution.
> 
> 
> >
> >>
> > --
> > David.
> >>
> >>
> >>
> >> Can you please help me how to use this if condition in your coding or
> >> we can also do it by using some other condition rather than if
> >> condition?
> >>
> >
> 
> 
> David Winsemius, MD
> West Hartford, CT
> 
> ______________________________________________
> R-help op r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list