integerOrNumeric {ClassifyR} | R Documentation

## Union of a Integer and a Numeric

### Description

Allows the same S4 subsetting function to be specified for `object[i]` and `object[i:j]`, where `i` and `j` are integers.

### Author(s)

Dario Strbenac

### Examples

      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.

[Package ClassifyR version 2.2.6 Index]