Coerce

as_count(from)

as_frequency(from)

as_incidence(from)

as_occurrence(from)

as_similarity(from)

# S4 method for ANY
as_count(from)

# S4 method for ANY
as_frequency(from)

# S4 method for ANY
as_incidence(from)

# S4 method for ANY
as_occurrence(from)

# S4 method for ANY
as_similarity(from)

Arguments

from

A numeric matrix or data.frame to be coerced.

Value

A CountMatrix or an IncidenceMatrix.

Details

The following methods coerce a matrix or data.frame to a *Matrix object:

MethodTarget
as_countCountMatrix
as_frequencyFrequencyMatrix
as_incidenceIncidenceMatrix
as_occurrenceOccurrenceMatrix
as_similaritySimilarityMatrix

See also

Examples

## Create a count matrix A1 <- CountMatrix(data = sample(0:10, 100, TRUE), nrow = 10, ncol = 10) ## Coerce counts to frequencies B <- as_frequency(A1) ## Row sums are internally stored before coercing to a frequency matrix ## (use totals() to get these values) ## This allows to restore the source data A2 <- as_count(B) all(A1 == A2)
#> [1] TRUE
## Coerce to presence/absence C <- as_incidence(A1) ## Coerce to a co-occurrence matrix D <- as_occurrence(A1)