Description Author(s) Examples
Allows the same S4 subsetting function to be specified for object[i]
and
object[i:j]
, where i
and j
are integers.
Dario Strbenac
1 2 3 4 5 6 7 8 9 10 | setClass("Container", representation(scores = "numeric"))
setMethod("[", c("Container", "integerOrNumeric", "missing", "ANY"),
function(x, i, j, ..., drop = TRUE)
{
new("Container", scores = x@scores[i])
})
dataset <- new("Container", scores = 1:10)
dataset[1] # 1 is numeric.
dataset[4:6] # 4:6 is a sequence of integers.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.