The function returns extracts of a data vector using two vector defining begin and end coordinates. An offset can be used.
1  segmentize(x, begin, end, offset=1, margin=1, invert=FALSE)

x 

begin 

end 

offset 

margin 

invert 

The inversion option internally operates using logical values.
As a consequence, when begin
and end
define overlapping
regions, in effect the union of these regions is removed,
because regions are only retained when they are not covered by any
segment defined by begin
and end
.
Integer vector
Wolfgang Kaisers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  # Create data vector
x < rep(0, 11)
x[3:5] < 1:3
x[7:9] < 4:6
names(x) < 10:20
# Define extracted segments
sgb < c(3, 7)
sge < c(5, 9)
sgm < segmentize(x, sgb, sge)
names(sgm) < segmentize(names(x), sgb, sge)
# Use offset
offset < 10
sgb < c(12, 16)
sge < c(14, 18)
segmentize(x, sgb, sge, offset)
# Matrix
m < matrix(0L, nrow=11, ncol=5)
rownames(m) < 10:20
colnames(m) < letters[1:5]
for(i in 1:5)
m[c(3:5, 7:9), i] < c(1:3, 4:6) * i
ms < segmentize(m, sgb, sge, offset)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.