Learn R Programming

proxyC (version 0.5.0)

mask: Create a pattern matrix for masking

Description

Create a pattern matrix for simil() or dist() to enable masked similarity computation. If the matrix is passed to the function, it computes similarity scores only for cells with TRUE.

Usage

mask(x, y = NULL)

Value

a sparse logical matrix with TRUE for matched pairs.

Arguments

x

a numeric or character vector matched against each other.

y

a numeric or character vector matched against x if provided.

Examples

Run this code
mt1 <- Matrix::rsparsematrix(100, 6, 1.0)
colnames(mt1) <- c("a", "a", "d", "d", "e", "e")
mt2 <- Matrix::rsparsematrix(100, 5, 1.0)
colnames(mt2) <- c("a", "b", "c", "d", "e")

(msk <- mask(colnames(mt1), colnames(mt2)))
simil(mt1, mt2, margin = 2, mask = msk, drop0 = TRUE)

Run the code above in your browser using DataLab