Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rlebdm

RLE-Compressed Boolean Dyad Matrix


Description

A simple class representing boolean (logical) square matrix run-length encoded in a column-major order.

Usage

rlebdm(x, n)

as.rlebdm(x, ...)

## S3 method for class 'matrix'
as.rlebdm(x, ...)

## S3 method for class 'edgelist'
as.rlebdm(x, ...)

## S3 method for class 'network'
as.rlebdm(x, ...)

## S3 method for class 'rlebdm'
as.matrix(x, ...)

## S3 method for class 'rlebdm'
dim(x)

## S3 method for class 'rlebdm'
print(x, compact = TRUE, ...)

## S3 method for class 'rlebdm'
Ops(e1, e2)

## S3 method for class 'rlebdm'
Math(x, ...)

## S3 method for class 'rlebdm'
compress(x, ...)

## S3 method for class 'rlebdm'
as.edgelist(x, prototype = NULL, ...)

Arguments

x

for rlebdm(), an rle() object or a vector that is converted to one; it will be coerced to logical() before processing; for as.rlebdm.matrix(), a matrix.

n

the dimensions of the square matrix represented.

...

additional arguments, currently unused.

compact

whether to print the matrix compactly (dots and stars) or to print it as a logical matrix.

e1, e2

arguments to the unary (e1) or the binary (e1 and e2) operators.

prototype

an optional network with network attributes that are transferred to the edgelist and will filter it (e.g., if the prototype network is given and does not allow self-loops, the edgelist will not have self-loops either,e ven if the dyad matrix has non-FALSE diagonal).

Methods (by generic)

  • as.rlebdm: Convert a square matrix of mode coercible to logical to an rlebdm.

  • as.rlebdm: Convert an object of class edgelist to an rlebdm object whose cells in the edge list are set to TRUE and whose other cells are set to FALSE.

  • as.rlebdm: Convert an object of class network to an rlebdm object whose cells corresponding to extant edges are set to TRUE and whose other cells are set to FALSE.

  • compress: Compress the rle data structure in the rlebdm by merging successive runs with identical values.

  • as.edgelist: Convert an rlebdm object to an edgelist: a two-column integer matrix giving the cells with TRUE values.

Note

The arithmetic operators are mathematical functions are implemented for the Ops and the Math group generics and therefore work for almost all of them automatically. To preserve the integrity of the data structure, the results are cast to logical before return.

See Also

Examples

# From a vector
rlebdm(rep(rep(c(0,1),each=3),14)[seq_len(81)], 9)

# From a constant
rlebdm(1, 3)

# Large matrix (overflowing .Machine$integer.max)
big <- rlebdm(1, 50000)
unclass(big) # Represented as two runs
stopifnot(length(big)==50000^2)

ergm

Fit, Simulate and Diagnose Exponential-Family Models for Networks

v3.11.0
GPL-3 + file LICENSE
Authors
Mark S. Handcock [aut], David R. Hunter [aut], Carter T. Butts [aut], Steven M. Goodreau [aut], Pavel N. Krivitsky [aut, cre] (<https://orcid.org/0000-0002-9101-3362>), Martina Morris [aut], Li Wang [ctb], Kirk Li [ctb], Skye Bender-deMoll [ctb], Chad Klumb [ctb], Michał Bojanowski [ctb], Ben Bolker [ctb]
Initial release
2020-10-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.