Skip to contents

Getters and setters to retrieve or set parts of an object.

Usage

has_groups(x)

get_groups(x)

set_groups(x) <- value

get_samples(x)

set_samples(x) <- value

has_dates(x)

get_dates(x)

set_dates(x) <- value

has_terminus(x)

get_terminus(x)

set_terminus(x) <- value

get_tpq(x)

set_tpq(x) <- value

get_taq(x)

set_taq(x) <- value

get_totals(x)

set_totals(x) <- value

# S4 method for AbundanceMatrix
has_groups(x)

# S4 method for AbundanceMatrix
get_groups(x)

# S4 method for AbundanceMatrix
get_samples(x)

# S4 method for AbundanceMatrix
has_dates(x)

# S4 method for AbundanceMatrix
get_dates(x)

# S4 method for AbundanceMatrix
has_terminus(x)

# S4 method for AbundanceMatrix
get_terminus(x)

# S4 method for AbundanceMatrix
get_tpq(x)

# S4 method for AbundanceMatrix
get_taq(x)

# S4 method for AbundanceMatrix
get_totals(x)

# S4 method for OccurrenceMatrix
get_totals(x)

# S4 method for AbundanceMatrix
set_groups(x) <- value

# S4 method for AbundanceMatrix
set_samples(x) <- value

# S4 method for AbundanceMatrix,`NULL`
set_dates(x) <- value

# S4 method for AbundanceMatrix,numeric
set_dates(x) <- value

# S4 method for AbundanceMatrix,`NULL`
set_terminus(x) <- value

# S4 method for AbundanceMatrix,list
set_terminus(x) <- value

# S4 method for AbundanceMatrix,`NULL`
set_tpq(x) <- value

# S4 method for AbundanceMatrix,numeric
set_tpq(x) <- value

# S4 method for AbundanceMatrix,`NULL`
set_taq(x) <- value

# S4 method for AbundanceMatrix,numeric
set_taq(x) <- value

# S4 method for AbundanceMatrix
set_totals(x) <- value

Arguments

x

An object from which to get or set element(s) (typically an AbundanceMatrix object).

value

A possible value for the element(s) of x.

Value

  • set_*() returns an object of the same sort as x with the new values assigned.

  • get_*() returns the part of x.

  • has_*() returns a logical scalar.

Details

get_samples(x) and get_samples(x) <- value

Get or set the sample names of x.

get_groups(x) and set_groups(x) <- value

Get or set the groups of x.

get_dates(x) and set_dates(x) <- value

Get or set the dates of x.

get_terminus(x) and set_terminus(x) <- value

Get or set the chronology of x. value must be a list with components tpq (TPQ - terminus post quem) and taq (TAQ - terminus ante quem).

get_tpq(x) and set_tpq(x) <- value, get_taq(x) and set_taq(x) <- value

Get or set the TPQ/TAQ of x.

Chronology

The way chronological information is handled is somewhat opinionated. Sub-annual precision is overkill/meaningless in most situations: dates are assumed to be expressed in years CE and are stored as integers (values are coerced with as.integer() and hence truncated towards zero).

See also

Other mutators: subset(), summary()

Author

N. Frerebeau

Examples

## Create a data.frame
X <- matrix(data = sample(0:10, 50, TRUE), nrow = 10, ncol = 5)
Y <- as.data.frame(X)

## Coerce to a count matrix
Z <- as_count(Y)

## Set/get groups
set_samples(Z) <- rep(c("a", "b", "c", "d", "e"), each = 2)
get_samples(Z)
#>  [1] "a" "a" "b" "b" "c" "c" "d" "d" "e" "e"

## Set/get groups
set_groups(Z) <- rep(c("A", "B"), each = 5)
get_groups(Z)
#>  [1] "A" "A" "A" "A" "A" "B" "B" "B" "B" "B"

## Get/get TPQ/TAQ
chrono <- list(
  tpq = sample(1301:1400, 10, replace = TRUE),
  taq = sample(1451:1500, 10, replace = TRUE)
)
set_terminus(Z) <- chrono
get_terminus(Z)
#>        tpq  taq
#> row1  1386 1485
#> row2  1317 1474
#> row3  1374 1454
#> row4  1368 1491
#> row5  1362 1463
#> row6  1336 1462
#> row7  1380 1458
#> row8  1366 1486
#> row9  1318 1475
#> row10 1398 1497

## Collection of features
as_features(Z)
#>       V1 V2 V3 V4 V5 samples group dates  tpq  taq
#> row1   7  9  8  4  3       a     A    NA 1386 1485
#> row2   8  5  7  9  5       a     A    NA 1317 1474
#> row3   8  6 10  4  6       b     A    NA 1374 1454
#> row4   8  0  0  8  1       b     A    NA 1368 1491
#> row5   9 10 10  4  9       c     A    NA 1362 1463
#> row6   3  2  6  3  8       c     B    NA 1336 1462
#> row7   0  3  1  5  7       d     B    NA 1380 1458
#> row8   2  7  3 10  3       d     B    NA 1366 1486
#> row9   0  9  0  0  8       e     B    NA 1318 1475
#> row10  2  4  8  4  1       e     B    NA 1398 1497

## Summarize data
summary(Z)
#> <AbundanceSummary: 10 x 5>
#> A ------------------------------------------------------------------------------
#> * Observations: 5
#> * Variables: 5
#> * Replicated measurements: TRUE
#> * Chronology: 1317 - 1491 (year CE)
#> B ------------------------------------------------------------------------------
#> * Observations: 5
#> * Variables: 5
#> * Replicated measurements: TRUE
#> * Chronology: 1318 - 1497 (year CE)
#> --------------------------------------------------------------------------------