Coerce

as_count(from)

as_abundance(from)

as_incidence(from)

as_occurrence(from)

as_similarity(from)

as_features(from)

as_stratigraphy(from)

# S4 method for ANY
as_count(from)

# S4 method for ANY
as_abundance(from)

# S4 method for ANY
as_incidence(from)

# S4 method for ANY
as_occurrence(from)

# S4 method for ANY
as_similarity(from)

# S4 method for ANY
as_stratigraphy(from)

# S4 method for Matrix
as_features(from)

Arguments

from

A numeric matrix or data.frame to be coerced.

Value

A coerced object.

Details

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

MethodTargetDetails
as_countCountMatrixabsolute frequency data
as_abundanceAbundanceMatrixrelative frequency data
as_incidenceIncidenceMatrixpresence/absence data
as_occurrenceOccurrenceMatrixco-occurrence
as_similaritySimilarityMatrix(dis)similarity
as_stratigraphyStratigraphicMatrixstratigraphic relationships

as_features converts an Matrix object to a collection of features (i.e. adata.frame with dates and coordinates columns).

as_stratigraphy converts a set of stratigraphic relationships (edges) to a stratigraphic (adjacency) matrix. from can be a matrix, list, or data.frame: the first column/component is assumed to contain the bottom units and the second the top units.

See also

Examples

## Create a count matrix A0 <- matrix(data = sample(0:10, 100, TRUE), nrow = 10, ncol = 10) ## Coerce to absolute frequencies A1 <- as_count(A0) ## Coerce to relative frequencies B <- as_abundance(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) ## Collection of features set_dates(A1) <- matrix(sample(0:10, 20, TRUE), nrow = 10, ncol = 2) set_coordinates(A1) <- matrix(sample(0:10, 30, TRUE), nrow = 10, ncol = 3) as_features(A1)
#> SITE X Y Z DATE_VALUE DATE_ERROR V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 #> 1 1 8 7 3 0 9 5 2 3 5 7 9 4 2 1 5 #> 2 2 4 1 1 9 9 8 10 0 10 2 5 6 0 6 10 #> 3 3 8 0 4 2 8 9 9 6 6 8 8 4 9 6 5 #> 4 4 5 8 0 4 4 8 9 0 9 0 10 10 1 9 1 #> 5 5 7 8 4 4 3 4 9 3 2 0 9 0 3 7 5 #> 6 6 10 2 9 2 0 5 10 2 5 5 3 4 9 0 10 #> 7 7 7 9 3 2 9 5 9 7 1 8 7 1 7 1 0 #> 8 8 5 2 7 4 8 0 10 1 9 8 6 8 6 3 2 #> 9 9 0 5 4 8 3 6 2 6 9 0 6 0 3 0 1 #> 10 10 7 0 6 9 9 7 7 4 5 5 10 7 4 10 9