Merge vector-like objects
merge method for vector-like objects.
Vector-like objects, typically all of the same class and typically not list-like objects (even though some list-like objects like Ranges and DNAStringSet are supported). Duplicated elements in each object are removed with a warning.
To be used only when merging 2 objects (binary merge).
Whether to sort the merged result.
merge method acts much like
except for 3 important differences:
The matching is based on the vector values, not arbitrary columns in a table.
Self merging is a no-op if
sort=FALSE(or object already sorted) and if the object has no duplicates.
mergemethod accepts an arbitrary number of vector-like objects (n-ary merge).
If some of the objects to merge are list-like objects not supported by
the method described here, then the merging is simply done by calling
base::merge() on the objects. This might succeed or not...
A vector-like object of the same class as the input objects (if they all have the same class) containing the merged vector values and metadata columns.
The Vector class.
Vector-comparison for comparing and ordering vector-like objects.
Vector-setops for set operations on vector-like objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
library(GenomicRanges) x <- GRanges(c("chr1:1-1000", "chr2:2000-3000"), score=c(0.45, 0.1), a1=c(5L, 7L), a2=c(6, 8)) y <- GRanges(c("chr2:150-151", "chr1:1-10", "chr2:2000-3000"), score=c(0.7, 0.82, 0.1), b1=c(0L, 5L, 1L), b2=c(1, -2, 1)) merge(x, y) merge(x, y, all=TRUE) merge(x, y, all.x=TRUE) merge(x, y, all.y=TRUE) ## Shared metadata columns must agree: mcols(x)$score <- 0.11 #merge(x, y) # error! ## NAs agree with anything: mcols(x)$score <- NA merge(x, y)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.