Skip to contents

Given a data frame of samples with columns ID and text, this function generates all unordered pairs (combinations) of samples. Each pair appears exactly once. The first and second positions follow the input row order; IDs are not sorted lexicographically. This function only prepares data and makes no provider requests.

Usage

make_pairs(samples)

Arguments

samples

A tibble or data frame with columns ID and text.

Value

A tibble with columns:

  • ID1, text1

  • ID2, text2

Details

With N samples there are choose(N, 2) pairs: 20 samples produce 190 pairs, while 100 produce 4,950. Use randomize_pair_order() to vary which sample appears first, and plan the comparison budget before submission.

Examples

samples <- tibble::tibble(
  ID   = c("S1", "S2", "S3"),
  text = c("Sample 1", "Sample 2", "Sample 3")
)

pairs_all <- make_pairs(samples)
pairs_all
#> # A tibble: 3 × 4
#>   ID1   text1    ID2   text2   
#>   <chr> <chr>    <chr> <chr>   
#> 1 S1    Sample 1 S2    Sample 2
#> 2 S1    Sample 1 S3    Sample 3
#> 3 S2    Sample 2 S3    Sample 3

# Using the built-in example data
data("example_writing_samples")
pairs_example <- make_pairs(example_writing_samples)
nrow(pairs_example) # should be choose(20, 2) = 190
#> [1] 190