# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab