rep_vt: Virtual Replication of Vectors

Description Usage Arguments Value Slots Creating Objects Methods Author(s) See Also Examples

View source: R/rep_vt.R

Description

The rep_vt class simulates the behavior of the base function rep without actually allocating memory for the duplication. Only the original vector and the expected length of the result are stored. All attributes of the original vector (including names) are dropped.

Usage

1
2
3
4
## Instance creation
rep_vt(x, times, length.out = length(x) * times)

## Additional methods documented below

Arguments

x

A vector (of any mode).

times

The number of times to repeat the whole vector.

length.out

The desired length of the result.

Value

An object of class rep_vt.

Slots

data:

The original vector.

length:

The expected length of the repeated virtual vector.

Creating Objects

rep_vt instances can be created through rep_vt().

Methods

Standard generic methods:

x[i]:

Get the elements of the uncompressed vector.

x[[i]]:

Get a single element of the uncompressed vector.

length(x):

Get the length of the uncompressed vector.

Author(s)

Kylie A. Bemis

See Also

[base]{rep}

Examples

1
2
3
4
5
6
7
## Create a rep_vt vector
init <- 1:3
x <- rep(init, length.out=100)
y <- rep_vt(init, length.out=100)

# Check that their elements are equal
x == y[]

matter documentation built on Nov. 8, 2020, 6:15 p.m.