Creating new objects

The easiest way to create a tidyged object is to import an existing GEDCOM file. This functionality is provided by the tidyged.io package.

A minimal tidyged object can be created using an empty gedcom() call:

library(tidyged)

gedcom() |> 
  knitr::kable()
level record tag value
0 HD HEAD
1 HD GEDC
2 HD VERS 5.5.5
2 HD FORM LINEAGE-LINKED
3 HD VERS 5.5.5
1 HD CHAR UTF-8
1 HD DEST gedcompendium
1 HD SOUR gedcompendium
2 HD NAME The ‘gedcompendium’ ecosystem of packages for the R language
2 HD CORP Jamie Lendrum
3 HD ADDR
3 HD EMAIL
3 HD WWW https://jl5000.github.io/tidyged/
1 HD DATE 22 JUN 2022
1 HD LANG English
1 HD SUBM @U1@
0 @U1@ SUBM
1 @U1@ NAME runner
1 @U1@ CHAN
2 @U1@ DATE 22 JUN 2022
0 TR TRLR

A tidyged object actually comes pre-populated with quite a lot of information (more so than a minimal GEDCOM file). Information about the tidyged package (as the system/product creating the file) is given in the appropriate places, as well as a default language (English), and submitter details taken from your computer username.

Submitter

You can use different information for many values using the parameters of the gedcom() function. The first argument of the function is a subm() object giving details of the submitter:

submitter <- subm(name = "The name of the submitter",
                  subm_address = address(local_address_lines = "123 Penny Lane Drive",
                                         city = "Orlando",
                                         state = "Florida",
                                         postal_code = "32836",
                                         country = "United States of America",
                                         phone_number = "123-456-789",
                                         email = "email@domain.com",
                                         fax = "00000",
                                         web_page = "http://www.whousesfaxanymore.com"),
                  subm_notes = "The information given above is dummy data")

gedcom(submitter) |> 
  knitr::kable()
level record tag value
0 HD HEAD
1 HD GEDC
2 HD VERS 5.5.5
2 HD FORM LINEAGE-LINKED
3 HD VERS 5.5.5
1 HD CHAR UTF-8
1 HD DEST gedcompendium
1 HD SOUR gedcompendium
2 HD NAME The ‘gedcompendium’ ecosystem of packages for the R language
2 HD CORP Jamie Lendrum
3 HD ADDR
3 HD EMAIL
3 HD WWW https://jl5000.github.io/tidyged/
1 HD DATE 22 JUN 2022
1 HD LANG English
1 HD SUBM @U1@
0 @U1@ SUBM
1 @U1@ NAME The name of the submitter
1 @U1@ ADDR
2 @U1@ ADR1 123 Penny Lane Drive
2 @U1@ CITY Orlando
2 @U1@ STAE Florida
2 @U1@ POST 32836
2 @U1@ CTRY United States of America
1 @U1@ PHON 123-456-789
1 @U1@ EMAIL
1 @U1@ FAX 00000
1 @U1@ WWW http://www.whousesfaxanymore.com
1 @U1@ NOTE The information given above is dummy data
1 @U1@ CHAN
2 @U1@ DATE 22 JUN 2022
0 TR TRLR

Other header parameters

The remaining arguments of the gedcom() function give further information about the file and the information held within it:

gedcom(submitter_details = subm(),
       gedcom_description = "Maternal ancestors of Jamie",
       gedcom_copyright = "No copyright",
       source_data_name = "Some CD I found in the basement",
       source_data_date = date_exact(2009, 5, 12),
       source_data_copyright = "No data copyright",
       receiving_system = "tidyged",
       language = "English") |> 
  knitr::kable()
level record tag value
0 HD HEAD
1 HD GEDC
2 HD VERS 5.5.5
2 HD FORM LINEAGE-LINKED
3 HD VERS 5.5.5
1 HD CHAR UTF-8
1 HD DEST tidyged
1 HD SOUR gedcompendium
2 HD NAME The ‘gedcompendium’ ecosystem of packages for the R language
2 HD CORP Jamie Lendrum
3 HD ADDR
3 HD EMAIL
3 HD WWW https://jl5000.github.io/tidyged/
2 HD DATA Some CD I found in the basement
3 HD DATE 12 MAY 2009
3 HD COPR No data copyright
1 HD DATE 22 JUN 2022
1 HD LANG English
1 HD SUBM @U1@
1 HD COPR No copyright
1 HD NOTE Maternal ancestors of Jamie
0 @U1@ SUBM
1 @U1@ NAME runner
1 @U1@ CHAN
2 @U1@ DATE 22 JUN 2022
0 TR TRLR

Note that:

  • The gedcom_description parameter should describe the type of genealogical data contained in the file;
  • The date associated with the source data must be given as a date_exact() object to ensure it is formatted correctly (see vignette("dates") for more information on dates);
  • The receiving_system should be left to its default value, unless you are specifically intending on passing it to a different system.

Subsetting an existing object

You can also create a new tidyged object by subsetting an existing object. See the tidyged.utils package.

The split_gedcom() function from the tidyged.utils package subsets a tidyged object. This will retain the header and submitter information from the original object.

unique(sample555$record)
#>  [1] "HD"   "@U1@" "@I1@" "@I2@" "@I3@" "@F1@" "@F2@" "@S1@" "@R1@" "TR"

unique(tidyged.utils::split_gedcom(sample555, c("@I1@", "@I2@"))$record)
#> Some dead record references have been removed: @S1@, @F1@, @F2@
#> [1] "HD"   "@U1@" "@I1@" "@I2@" "TR"

This is especially powerful when paired with the get_descendants() function (see vignette("maintenance_functions")), where you can create a separate object for an entire branch.

Next article: Referencing records >