Hello


I have 2 data frames df1 and df2. I would like to create a
new data frame new_df which will contain only the common rows based on the first 2
columns (chrN and start). The column score in the new data frame
should
be replaced with a column containing the average score (average_score) from df1
and df2. 




df1= data.frame(chrN= c(“chr1”, “chr1”, “chr1”, “chr1”, “chr2”,
“chr2”, “chr2”), 


start= c(23, 82, 95, 108, 95, 108, 121),


end= c(33, 92, 105, 118, 105, 118, 131),


score= c(3, 6, 2, 4, 9, 2, 7))


 


df2= data.frame(chrN= c(“chr1”, “chr2”, “chr2”, “chr2” , “chr2”),


start= c(23, 50, 95, 20, 121),


end= c(33, 60, 105, 30, 131),


score= c(9, 3, 7, 7, 3))


 


new_df= data.frame(chrN= c(“chr1”, “chr2”, “chr2”),


start= c(23, 95, 121),


end= c(33, 105, 131),


average_score= c(6, 8, 5))


 
Thank you for your help
Joseph








      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 

	[[alternative HTML version deleted]]

