A collection of classes that represent archaeological data. This package provides a set of S4 classes that extend the basic matrix data type (absolute/relative frequency, presence/absence data, co-occurrence matrix, etc.) upon which package developers can build subclasses. It also provides a set of generic methods (mutators and coercion mechanisms) and functions (e.g. predicates). In addition, a few classes of general interest (e.g. that represent stratigraphic relationships) are implemented.
You can install the released version of arkhe from CRAN with:
Or install the development version from GitHub with:
arkhe provides a set of S4 classes that extend the basic matrix
data type. These new classes represent different special types of matrix.
CountMatrix
represents absolute frequency data,AbundanceMatrix
represents relative frequency data,OccurrenceMatrix
represents a co-occurrence matrix,SimilarityMatrix
represents a (dis)similarity matrix,IncidenceMatrix
represents presence/absence data,StratigraphicMatrix
represents stratigraphic relationships.It assumes that you keep your data tidy: each variable (type/taxa) must be saved in its own column and each observation (assemblage/sample) must be saved in its own row.
These new classes are of simple use, on the same way as the base matrix
:
# Define a count data matrix
quanti <- CountMatrix(data = sample(0:10, 100, TRUE), nrow = 10, ncol = 10)
# Define a logical matrix
# Data will be coerced with as.logical()
quali <- IncidenceMatrix(data = sample(0:1, 100, TRUE), nrow = 10, ncol = 10)
arkhe uses coercing mechanisms (with validation methods) for data type conversions:
## 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 get_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)
Represent stratigraphic relationships:
# Principles of Archaeological Stratigraphy, fig. 12
harris <- read.table(
header = TRUE,
text = "lower upper
2 1
3 1
4 1
5 2
5 3
5 4
6 5
7 1
7 6
8 1
8 6
9 7
9 8"
)
as_stratigraphy(harris)
#> <StratigraphicMatrix: aca09a25-5637-4d61-a55b-13cfe70e0401>
#> 9 x 9 stratigraphic matrix:
#> upper
#> lower 1 2 3 4 5 6 7 8 9
#> 1 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> 2 TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> 3 TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> 4 TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> 5 FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
#> 6 FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE
#> 7 TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE
#> 8 TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE
#> 9 FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE
Please note that the arkhe project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.