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)

from | A numeric |
---|

A CountMatrix or an IncidenceMatrix.

The following methods coerce a `matrix`

or `data.frame`

to a
`*Matrix`

object:

Method | Target |

`as_count` | CountMatrix |

`as_frequency` | FrequencyMatrix |

`as_incidence` | IncidenceMatrix |

`as_occurrence` | OccurrenceMatrix |

`as_similarity` | SimilarityMatrix |

Other matrix: `CountMatrix-class`

,
`FrequencyMatrix-class`

,
`IncidenceMatrix-class`

,
`LogicalMatrix-class`

,
`Matrix-class`

,
`NumericMatrix-class`

,
`OccurrenceMatrix-class`

,
`SimilarityMatrix-class`

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