Getters and setters to extract or replace parts of an object.

get_id(object)

get_method(object)

get_units(object)

get_totals(object)

set_totals(object) <- value

# S4 method for ANY
get_id(object)

# S4 method for AbundanceMatrix
get_totals(object)

# S4 method for SimilarityMatrix
get_method(object)

# S4 method for StratigraphicMatrix
get_units(object)

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

Arguments

object

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

value

A possible value for the element(s) of object (see below).

Value

An object of the same sort as object with the new values assigned.

See also

Other mutator: subset()

Examples

## Create a count data matrix A1 <- CountMatrix(data = sample(0:10, 100, TRUE), nrow = 10, ncol = 10) ## Access get_id(A1)
#> [1] "65fda839-86ee-473a-912a-f4978acc604c"
dim(A1) # Get the matrix dimensions
#> [1] 10 10
colnames(A1) <- letters[11:20] # Set the column names colnames(A1) # Get the column names
#> [1] "k" "l" "m" "n" "o" "p" "q" "r" "s" "t"
rownames(A1) <- LETTERS[1:10] # Set the row names rownames(A1) # Get the rownames
#> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
## Subset A1[[1]] # Get the first value
#> [1] 1
A1[, ] # Get all values
#> k l m n o p q r s t #> A 1 5 7 10 10 4 2 0 4 6 #> B 10 7 1 4 10 3 2 8 9 6 #> C 1 1 6 3 0 10 8 9 9 10 #> D 4 6 10 9 4 6 7 4 3 2 #> E 4 1 6 5 0 9 1 9 8 7 #> F 7 2 10 6 1 5 4 3 7 3 #> G 4 9 9 9 5 1 1 10 4 0 #> H 8 0 9 5 0 5 2 10 5 3 #> I 6 9 1 0 10 7 7 7 3 0 #> J 8 4 0 9 6 8 10 10 0 6
A1[1, ] # Get the first row
#> k l m n o p q r s t #> 1 5 7 10 10 4 2 0 4 6
A1[c("A", "B", "C"), ] # Get the first three rows
#> k l m n o p q r s t #> A 1 5 7 10 10 4 2 0 4 6 #> B 10 7 1 4 10 3 2 8 9 6 #> C 1 1 6 3 0 10 8 9 9 10
A1[c("A", "B", "C"), 1] # Get the first three rows of the first column
#> A B C #> 1 10 1
A1[, 1, drop = FALSE] # Get the first column
#> k #> A 1 #> B 10 #> C 1 #> D 4 #> E 4 #> F 7 #> G 4 #> H 8 #> I 6 #> J 8
## Coerce counts to relative frequencies B <- as_abundance(A1) ## Row sums are internally stored before coercing to a frequency matrix get_totals(B) # Get row sums
#> A B C D E F G H I J #> 49 60 57 55 50 48 52 47 50 61
## This allows to restore the source data A2 <- as_count(B) all(A1 == A2)
#> [1] TRUE
## Coerce to a co-occurrence matrix B <- as_occurrence(A1)