Extract.rle: Indexing Methods for 'rle' Objects

Description Usage Arguments Details Value Examples

Description

These methods are defined and produce an error (except for character input) to future-proof code that depends on the rle package by preventing their use.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## S3 method for class 'rle'
x[i, ...]

## S3 replacement method for class 'rle'
x[i, ...] <- value

## S3 method for class 'rle'
x[[i, ...]]

## S3 replacement method for class 'rle'
x[[i, ...]] <- value

## S3 method for class 'rle'
x$name

## S3 replacement method for class 'rle'
x$name <- value

Arguments

x, i, name, value, ...

Arguments to indexing operators. See Extract documentation in the base package.

Details

At this time, the rle package does not support indexing operations by logical or numeric indices, but it is likely to do so in the future. Therefore, we reserve the syntax now to prevent users of this package from relying on the default behaviour of the indexing operators.

Value

At this time, all functions raise an error except for character indices. This behaviour can be overridden by setting options(rle.unclass_index=TRUE), which effectively unclasses the objects before indexing.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Indexing by character or by $ works, including sub-indexing.
x <- rle(1:5)
x[["values"]] <- 2:6
x
x$values[2:3] <- 7:8
x


## Not run: 
# Numerical indexing doesn't, unless `options(rle.unclass_index=TRUE)` is set.
x[1]
x[[1]]

## End(Not run)

statnet/rle documentation built on June 16, 2021, 6:24 p.m.