## Extract parts of a list of intervals
list <- IntervalList(c(1, 3, 5), c(2, 4, 6))
list[1] ## Extract the first interval
## Note that the output is an IntervalList object
list[[1]] ## The first interval is extracted as an IntervalData object
list[c(1, 3)] ## Extract the first and the third interval
## Extract parts of a matrix of intervals
m <- IntervalMatrix(matrix(c(1, 5, 2, 6, 6, 2, 7, 3, 3, 4, 4, 5), 2, 6))
m[1, 1] ## Extract the interval from the first row and first column
m[1,] ## Extract all the intervals from the first row
m[, 1] ## Extract all the intervals from the first column
m[, c(1, 3)] ## Extract the sub-matrix containing all the intervals
## from both first and third column of the original matrix
## Replace parts of a list of intervals
list[[1]]
list[[1]] <- IntervalData(0, 1)
list[[1]]
list[c(1, 3)]
list[c(1, 3)] <- IntervalList(c(0, 1), c(1, 2))
list[c(1, 3)]
## Replace parts of a matrix of intervals
m[1, 1]
m[1, 1] <- IntervalData(0, 1)
m[1, 1]
m[1, 1:2]
m[1, 1:2] <- IntervalList(c(0, 1), c(1, 2))
m[1, 1:2]
m[, c(1, 3)]
m[, c(1, 3)] <- IntervalMatrix(matrix(1:8, 2, 4))
m[, c(1, 3)]
Run the code above in your browser using DataLab