The ability to order records by type in a GEDCOM file is a task purely done for aesthetics - it has no functional value, other than perhaps making records easier to find. We can see in the example below that records are given in the order they were defined:
library(tidyged)
library(tidyged.utils)
some_unref <- gedcom(subm("Me")) |>
add_indi(qn = "Tom Smith") |>
add_indi(qn = "Tammy Smith") |>
add_indi(qn = "Alice White") |>
add_indi(qn = "Phil Brown") |>
add_famg() |>
add_famg() |>
add_famg() |>
add_famg() |>
add_famg() |>
add_famg() |>
add_repo("Test repo")
#> Added Unknown Individual: @I1@
#> Added Unknown Individual: @I2@
#> Added Unknown Individual: @I3@
#> Added Unknown Individual: @I4@
#> Added Family Group: @F1@
#> Added Family Group: @F2@
#> Added Family Group: @F3@
#> Added Family Group: @F4@
#> Added Family Group: @F5@
#> Added Family Group: @F6@
#> Added Repository: @R1@
unique(some_unref$record)
#> [1] "HD" "@U1@" "@I1@" "@I2@" "@I3@" "@I4@" "@F1@" "@F2@" "@F3@" "@F4@"
#> [11] "@F5@" "@F6@" "@R1@" "TR"
We now use the arrange_records()
function to arrange
them in a specific order, given by a character string giving the first
initial of each record type (header, trailer, and submitter records do
not move):
The order_famg_children_all()
function ensures all
children are represented in Family Group records in order of date of
birth. This is an extension of the order_famg_children()
function found in the tidyged
package but applies to all
Family Group records.
With all records and many subrecords, it’s possible to include custom notes to augment the information provided. These can either be the notes themselves, or a pointer to a top level Note record:
notes <- gedcom(subm("Me")) |>
add_note("This is a generic note.") |>
add_indi(indi_notes = c("This is a bespoke note.", "This is a generic note.")) |>
add_repo("My repository", repo_notes = c("This is a bespoke note.", "This is a generic note."))
#> Added Note: @N1@
#> Added Unknown Individual: @I1@
#> Added Repository: @R1@
knitr::kable(notes)
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 protected] | |
3 | HD | WWW | https://jl5000.github.io/tidyged/ |
1 | HD | DATE | 22 NOV 2024 |
1 | HD | LANG | English |
1 | HD | SUBM | @U1@ |
0 | @U1@ | SUBM | |
1 | @U1@ | NAME | Me |
1 | @U1@ | CHAN | |
2 | @U1@ | DATE | 22 NOV 2024 |
0 | @N1@ | NOTE | This is a generic note. |
1 | @N1@ | CHAN | |
2 | @N1@ | DATE | 22 NOV 2024 |
0 | @I1@ | INDI | |
1 | @I1@ | SEX | U |
1 | @I1@ | CHAN | |
2 | @I1@ | DATE | 22 NOV 2024 |
1 | @I1@ | NOTE | This is a bespoke note. |
1 | @I1@ | NOTE | This is a generic note. |
0 | @R1@ | REPO | |
1 | @R1@ | NAME | My repository |
1 | @R1@ | NOTE | This is a bespoke note. |
1 | @R1@ | NOTE | This is a generic note. |
1 | @R1@ | CHAN | |
2 | @R1@ | DATE | 22 NOV 2024 |
0 | TR | TRLR |
In the above example, there is a generic note recorded in a top level Note record. This same note message has been used for the individual and repository defined, but they have been repeated rather than pointing to the Note record. There is also a repeated bespoke note given in the Individual and Repository records.
The consolidate_notes()
function will simplify the file,
replacing note values with pointers to top level Note records (creating
them if necessary) if they are repeated:
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 protected] | |
3 | HD | WWW | https://jl5000.github.io/tidyged/ |
1 | HD | DATE | 22 NOV 2024 |
1 | HD | LANG | English |
1 | HD | SUBM | @U1@ |
0 | @U1@ | SUBM | |
1 | @U1@ | NAME | Me |
1 | @U1@ | CHAN | |
2 | @U1@ | DATE | 22 NOV 2024 |
0 | @N1@ | NOTE | This is a generic note. |
1 | @N1@ | CHAN | |
2 | @N1@ | DATE | 22 NOV 2024 |
0 | @I1@ | INDI | |
1 | @I1@ | SEX | U |
1 | @I1@ | CHAN | |
2 | @I1@ | DATE | 22 NOV 2024 |
1 | @I1@ | NOTE | @N2@ |
1 | @I1@ | NOTE | @N1@ |
0 | @R1@ | REPO | |
1 | @R1@ | NAME | My repository |
1 | @R1@ | NOTE | @N2@ |
1 | @R1@ | NOTE | @N1@ |
1 | @R1@ | CHAN | |
2 | @R1@ | DATE | 22 NOV 2024 |
0 | @N2@ | NOTE | This is a bespoke note. |
1 | @N2@ | CHAN | |
2 | @N2@ | DATE | 22 NOV 2024 |
0 | TR | TRLR |