check_ids_match: Check ids

View source: R/check-ids-match.R

check_ids_matchR Documentation

Check ids

Description

Compare IDs (such as individual IDs or specimen IDs) between two data frames.

Ensure that all individual IDs in two data frames match.

Ensure that all specimen IDS in two data frames match

Usage

check_ids_match(
  x,
  y,
  idcol = c("individualID", "specimenID"),
  xname = NULL,
  yname = NULL,
  bidirectional = TRUE
)

check_indiv_ids_match(x, y, xname = NULL, yname = NULL, bidirectional = TRUE)

check_specimen_ids_match(
  x,
  y,
  xname = NULL,
  yname = NULL,
  bidirectional = TRUE
)

Arguments

x, y

Data frames to compare

idcol

Name of column containing ids to compare

xname, yname

Names of x and y (to be used in resulting messages)

bidirectional

Should mismatches from both x and y be reported? Defaults to TRUE; if FALSE, will return only IDs in y that are not present in x (IDs in x but not y will be ignored).

Value

A condition object indicating whether IDs match ("check_pass") or not ("check_fail"). Mismatched IDs are included as data within the object.

Examples

a <- data.frame(individualID = LETTERS[1:3])
b <- data.frame(individualID = LETTERS[1:4])
check_ids_match(a, b, idcol = "individualID", xname = "a", yname = "b")
a <- data.frame(individualID = LETTERS[1:3])
b <- data.frame(individualID = LETTERS[1:4])
check_specimen_ids_match(a, b, "individual", "biospecimen")
a <- data.frame(specimenID = LETTERS[1:3])
b <- data.frame(specimenID = LETTERS[1:4])
check_specimen_ids_match(a, b, "biospecimen", "assay")

Sage-Bionetworks/dccvalidator documentation built on May 7, 2022, 10:32 a.m.