Subsets rows and columns like an ordinary tibble, but the class travels
only while the result still satisfies the contract: id1/id2
(both character) and dissim (numeric) all present. Dropping any of
them leaves something that can no longer be described as a pairwise
distance table, and the result is a plain tibble, without an error.
Value
The subset: still a pairwise_distances (or its
tale_distances/domain_distances subclass) if the contract
holds, otherwise a plain tibble.
Details
Squareness is not checked here (see distances_assert_square):
subsetting rows is an everyday way to end up with a non-square table.
See also
Other pairwise distances:
as.matrix.pairwise_distances(),
distances_assert_square(),
distances_restrict(),
is_pairwise_distances(),
pairwise_distances(),
rvd_dna_specificity,
tales_assign_domain_codes(),
tales_compare_distal(),
tales_compare_functal(),
tales_domain_distances(),
tales_group_hclust(),
tales_group_kmedoids(),
tales_tale_distances(),
validate_pairwise_distances()
Examples
d <- pairwise_distances(data.frame(
id1 = c("A1", "A1", "A2", "A2"),
id2 = c("A1", "A2", "A1", "A2"),
dissim = c(0, 35, 35, 0)
))
is_pairwise_distances(d[1:2, ]) # row subsetting never breaks the contract
#> [1] TRUE
class(d[, "id1"]) # dropping dissim/id2: the class steps aside
#> [1] "tbl_df" "tbl" "data.frame"