Coerce
as_long(from, ...) 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_similarity(from) # S4 method for ANY as_occurrence(from) # S4 method for ANY as_incidence(from) # S4 method for ANY as_stratigraphy(from) # S4 method for DataMatrix as_long(from, as_factor = FALSE) # S4 method for DataMatrix as_features(from)
from | An object to be coerced. |
---|---|
... | Currently not used. |
as_factor | A |
A coerced object.
The following methods coerce an object 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_stratigraphy | StratigraphicMatrix | stratigraphic relationships |
**Note that as_count
rounds numeric values to zero decimal places and
then coerces to integer as by as.integer
.**
Method | Target | Details |
as.matrix | matrix | S3 matrix |
as.data.frame | data.frame | S3 data frame |
as_long | data.frame | long S3 data frame |
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 (adjacency).
as_features
converts an DataMatrix object to a
collection of features: a data.frame
with all informations
as extra columns (result may differ according to the class of from
).
Other matrix:
AbundanceMatrix-class
,
CountMatrix-class
,
DataMatrix-class
,
GenericMatrix-class
,
IncidenceMatrix-class
,
OccurrenceMatrix-class
,
SimilarityMatrix-class
,
StratigraphicMatrix-class
N. Frerebeau
## Create a count matrix A0 <- matrix(data = sample(0:10, 100, TRUE), nrow = 10, ncol = 5) ## Coerce to absolute frequencies A1 <- as_count(A0) ## Coerce to relative frequencies B <- as_abundance(A1) ## Row sums are internally stored before coercing to relative frequencies ## (use get_totals() to retrieve 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) ## Coerce to an S3 matrix or data.frame X <- as.matrix(A1) all(A0 == X)#> [1] TRUE#> col1 col2 col3 col4 col5 #> row1 7 8 6 2 1 #> row2 6 8 3 6 1 #> row3 4 7 6 6 4 #> row4 5 10 0 4 4 #> row5 3 3 0 5 9 #> row6 3 7 7 7 2## 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)