interval_included | R Documentation |

Determine which intervals in the one set are completely included in the intervals of a second set.

```
## S4 method for signature 'Intervals,Intervals'
interval_included(from, to, check_valid = TRUE)
## S4 method for signature 'Intervals_full,Intervals_full'
interval_included(from, to, check_valid = TRUE)
```

`from` |
An |

`to` |
An |

`check_valid` |
Should |

A list, with one element for each row/component of `from`

. The
elements are vectors of indices, indicating which `to`

rows (or
components, for the `"numeric"`

method) are completely included
within each interval in `from`

. A list element of length 0
indicates no included elements. Note that empty `to`

elements are
not included in anything, and empty `from`

elements do not
include anything.

See `interval_overlap`

for partial overlaps – i.e., at at
least a point.

```
# Note that 'from' and 'to' contain valid but empty intervals.
to <- Intervals(
matrix(
c(
2, 6,
2, 8,
2, 9,
4, 4,
6, 8
),
ncol = 2, byrow = TRUE
),
closed = c( TRUE, FALSE ),
type = "Z"
)
from <- Intervals(
matrix(
c(
2, 8,
8, 9,
6, 9,
11, 12,
3, 3
),
ncol = 2, byrow = TRUE
),
closed = c( TRUE, FALSE ),
type = "Z"
)
rownames(from) <- letters[1:nrow(from)]
from
to
interval_included(from, to)
closed(to) <- TRUE
to
interval_included(from, to)
# Intervals_full
F <- FALSE
T <- TRUE
to <- Intervals_full(
rep( c(2,8), c(4,4) ),
closed = matrix( c(F,F,T,T,F,T,F,T), ncol = 2 ),
type = "R"
)
type( from ) <- "R"
from <- as( from, "Intervals_full" )
from
to
interval_included(from, to)
# Testing
B <- 1000
x1 <- rexp( B, 1/1000 )
s1 <- runif( B, max=5 )
x2 <- rexp( B, 1/1000 )
s2 <- runif( B, max=3 )
from <- Intervals_full( cbind( x1, x1 + s1 ) )
to <- Intervals_full( cbind( x2, x2 + s2 ) )
ii <- interval_included( from, to )
ii_match <- which( sapply( ii, length ) > 0 )
from[ ii_match[1:3], ]
lapply( ii[ ii_match[1:3] ], function(x) to[x,] )
included <- to[ unlist( ii ), ]
dim( included )
interval_intersection( included, interval_complement( from ) )
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.