Thanks for your reply, but both match and merge functions do not solve the problem because the range field might be different for two objects as exampled below. I  made a program using Python to solve this problem but hopefully some one in R should write a simple function for this problem. 



On Wednesday, October 16, 2013 10:23 AM, Michael Lawrence <lawrence.michael@gene.com> wrote:
 
If you just need to merge the Val from obj2 as a column in obj1, i.e., there is no need to add ranges from obj2 to obj1, then it's simple using match(). If you need the equivalent of merge(all=TRUE), then you need to convert to data frames, use merge() and convert back. There is a merge,VRanges method that does this. Nothing for GRanges yet though.




On Wed, Oct 16, 2013 at 7:15 AM, John linux-user <johnlinuxuser@yahoo.com> wrote:

Hello everyone,
>
>I am wondering how to simply merge two GRanges objects by range field and add the value by additional vector. For example, I have two objects below 
> 
>obj1 
>
>seqnames           ranges strand |       Val
>            <Rle>        <IRanges>  <Rle> | <integer>
>  [1] chr1_random [272531, 272571]      + |        88
>  [2] chr1_random [272871, 272911]      + |        45
>
>obj2
> seqnames           ranges strand |       Val
>            <Rle>        <IRanges>  <Rle> | <integer>
>  [1] chr1_random [272531, 272581]      + |        800
>  [2] chr1_random [272850, 272911]      + |        450
>
>after merged, it should be an object as the following mergedObject and it would concern the differences in IRANGE data (e.g. 581 and 850 in obj2 above were different from those of obj1, which were 571 and 871 respectively)
>
>mergedObject
>
> seqnames           ranges strand                 |         object2Val   object1Val
>            <Rle>        <IRanges>  <Rle>         |         <integer>     <integer>
>  [1] chr1_random [272531, 272581]      + |        800               88
>  [2] chr1_random [272850, 272911]      + |        450               45
>
>
>
>
>On Tuesday, October 15, 2013 12:36 PM, Lukasz [guest] <guest@bioconductor.org> wrote:
>
>
	[[alternative HTML version deleted]]

