Learn R Programming

⚠️There's a newer version (1.10.0) of this package.Take me there.

arkhe

Overview

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.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
remotes::install_github("nfrerebeau/arkhe")

Usage

# Load the package
library(arkhe)
# See the vignette
utils::vignette("arkhe", package = "arkhe")

arkhe provides a set of S4 classes that extend the basic matrix data type. These new classes represent different special types of matrix.

  • Numeric matrix:
    • CountMatrix represents absolute frequency data,
    • AbundanceMatrix represents relative frequency data,
    • OccurrenceMatrix represents a co-occurrence matrix,
    • SimilarityMatrix represents a (dis)similarity matrix,
  • Logical 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: 25af4daf-398f-4e33-9b60-76f9e8904699>
#>  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

Contributing

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.

Copy Link

Version

Install

install.packages('arkhe')

Monthly Downloads

1,015

Version

0.2.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Nicolas Frerebeau

Last Published

December 18th, 2019

Functions in arkhe (0.2.0)

SimilarityMatrix-class

Similarity Matrix
arkhe-package

arkhe: Representation of Archaeological Data
NumericMatrix-class

Numeric Matrix
CountMatrix-class

Absolute Frequency Matrix
OccurrenceMatrix-class

Co-Occurrence Matrix
StratigraphicMatrix-class

Stratigraphic Matrix
IncidenceMatrix-class

Incidence Matrix
AbundanceMatrix-class

Relative Frequency Matrix
Matrix-class

Matrix
check-numeric

Check Numeric Values
conditions

Conditions
predicate-utils

Utility Predicates
check-type

Check Data Types
predicate-type

Type Predicates
check-attribute

Check Object Attributes
mutator

Get or Set Parts of an Object
predicate-graph

Graph Predicates
subset

Extract or Replace Parts of an Object
check-graph

Check Graph
arkhe-deprecated

Deprecated Methods
LogicalMatrix-class

Logical Matrix
generate_uuid

UUID
geography

Spatial Information
chronology

Chronological Information
coerce

Coerce
predicate-scalar

Scalar Type Predicates
predicate-trend

Numeric Trend Predicates
check-missing

Check Missing Values
check-matrix

Check Matrix
predicate-numeric

Numeric Predicates
predicate-matrix

Matrix Predicates