BumpyAtomicMatrix: The BumpyAtomicMatrix subclass

Description Details Examples

Description

A subclass of the BumpyMatrix where each entry is an atomic vector. One subclass is provided for each of the most common types.

Details

In the following code snippets, x is a BumpyDFrameMatrix.

Binary and unary operations are implemented by specializing Ops, Math and related group generics, and will usually return a new BumpyAtomicMatrix of the appropriate type. The exception is for Summary methods like max and min; these return an ordinary matrix where each entry contains a scalar value for the corresponding entry of x. Furthermore, range will return a 3-dimensional array containing the minimum and maximum for each entry of x.

Common mathematical operations are implemented that apply to each entry of the BumpyAtomicMatrix:

Additionally, common operations are implemented that apply to each entry of the BumpyCharacterMatrix and return a BumpyAtomicMatrix of the same dimensions and an appropriate type. This includes tolower, toupper, substr, substring, sub, gsub, grepl, grep, nchar, chartr, startsWith and endsWith. We also implement unstrsplit, which returns an ordinary matrix of the same dimensions containing the unsplit strings.

All methods implemented for the BumpyMatrix parent class are available here.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Mocking up a BumpyNumericList:
library(IRanges)
x <- splitAsList(runif(1000), factor(sample(50, 1000, replace=TRUE), 1:50))  

# Creating a BumpyNumericMatrix:
mat <- BumpyMatrix(x, c(10, 5))
mat[,1]

# Arithmetic operations:
(mat * 2)[,1]
(mat + mat * 5)[,1]

# Logical operations:
(mat < 0.5)[,1]
(mat > 0.5 & mat < 1)[,1]
(mat == mat)[,1]

# More statistics:
max(mat)
min(mat)
mean(mat)
sd(mat)
median(mat)

# Handling character vectors:
x <- splitAsList(sample(LETTERS, 100, replace=TRUE), 
    factor(sample(20, 100, replace=TRUE), 1:20))
cmat <- BumpyMatrix(x, c(5, 4))
cmat[,1]

tolower(cmat[,1])
grepl("A|E|I|O|U", cmat)[,1]
sub("A|E|I|O|U", "vowel", cmat)[,1]

LTLA/BumpyMatrix documentation built on July 5, 2021, 2:21 a.m.