find_xref: Find an xref of a record given a set of search terms

View source: R/find_xref.R

find_xrefR Documentation

Find an xref of a record given a set of search terms

Description

Find an xref of a record given a set of search terms

Usage

find_xref(
  gedcom,
  search_patterns,
  mode = "strict",
  multiple = FALSE,
  ignore_case = FALSE
)

Arguments

gedcom

A tidyged object.

search_patterns

A named vector of terms to search for (see Details).

mode

Whether to only return an xref if all patterns are matched ("strict"). A value of "best" will return the xref with the most matches. If either of these still result in more than one xref it will return an error unless multiple is TRUE.

multiple

If more than one xref is found (according to mode), whether to return all xrefs or throw an error.

ignore_case

Should case differences be ignored in the match?

Details

This is a helper function to identify the xref of a record given information such as a name or reference number. You provide a named search_patterns vector of namespaced tag-pattern pairs, such as:

c(INDI.NAME = "Homer", INDI.SEX = "M", INDI.BIRT.DATE = "JAN 1974")

If you're not sure what namespace to use, use the mutate_tag_namespace function.

The search patterns will be treated as regular expressions, so they will match a value if it contains the pattern provided. You can anchor your search pattern if you want an exact match, e.g. "^JAN 1974$". If you're not familiar with regular expressions, you may need to escape certain characters such as brackets and a full-stop/period (i.e. \\.).

Value

A vector of one or more xrefs.

Examples

find_xref(sample555, c(INDI.BURI.PLAC = "Spring Hill"), multiple = FALSE)
find_xref(sample555, c(INDI.SEX = "M"), multiple = TRUE)
find_xref(sample555, c(FAM.MARR.DATE = "1859"), multiple = FALSE)
find_xref(sample555, c(REPO.ADDR.CITY = "Salt Lake"), multiple = TRUE)
find_xref(sample555, c(INDI.NAME.SURN = "Williams", INDI.ADOP.DATE = "Never"), 
mode = "best", multiple = TRUE)

jl5000/tidygedcom documentation built on June 22, 2022, 5:16 p.m.