Learn R Programming

arkhe (version 0.2.2)

coerce: Coerce

Description

Coerce

Usage

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:

Method Target Details
as_count '>CountMatrix absolute frequency data
as_abundance '>AbundanceMatrix relative frequency data
as_incidence '>IncidenceMatrix presence/absence data
as_occurrence '>OccurrenceMatrix co-occurrence
as_similarity '>SimilarityMatrix (dis)similarity

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

Other matrix: AbundanceMatrix-class, CountMatrix-class, IncidenceMatrix-class, LogicalMatrix-class, Matrix-class, NumericMatrix-class, OccurrenceMatrix-class, SimilarityMatrix-class, StratigraphicMatrix-class

Examples

Run this code
# NOT RUN {
## 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)

## 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)
# }

Run the code above in your browser using DataLab