[R] For help in R coding

Bansal, Vikas vikas.bansal at kcl.ac.uk
Tue Jul 5 16:51:09 CEST 2011


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 at comcast.net]
Sent: Monday, July 04, 2011 12:11 AM
To: Bansal, Vikas
Cc: Dennis Murphy; r-help at 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 at 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



More information about the R-help mailing list