Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://jl5000.github.io/tidyged/

Create and summarise family tree GEDCOM files using tidy dataframes. (NOTE: tidyged et al will be superseded this year by a better package currently in development)
https://jl5000.github.io/tidyged/

Last synced: about 1 month ago
JSON representation

Create and summarise family tree GEDCOM files using tidy dataframes. (NOTE: tidyged et al will be superseded this year by a better package currently in development)

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# tidyged

[![R-CMD-check](https://github.com/jl5000/tidyged/workflows/R-CMD-check/badge.svg)](https://github.com/jl5000/tidyged/actions)
[![](https://codecov.io/gh/jl5000/tidyged/branch/master/graph/badge.svg)](https://codecov.io/gh/jl5000/tidyged)
[![CodeFactor](https://www.codefactor.io/repository/github/jl5000/tidyged/badge)](https://www.codefactor.io/repository/github/jl5000/tidyged)
[![](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)

> Families can be difficult - but the data describing them doesn't need to be

Create and summarise family tree GEDCOM files using tidy dataframes.

The package is part of the `gedcompendium` ecosystem of packages. This ecosystem enables the handling of `tidyged` objects (tibble representations of GEDCOM files), and the main package of this ecosystem is [`tidyged`](https://jl5000.github.io/tidyged/).

```{r, echo=FALSE, out.width="65%", fig.align='center'}
knitr::include_graphics("man/figures/allhex.png")
```

## Installation

You can install the development version from [GitHub](https://github.com/) with:

``` r
# install.packages("remotes")
remotes::install_github("jl5000/tidyged")
```

## Example

The intent is to allow the user to import GEDCOM files or create them from scratch using a `ggplot2` type interface; starting with a base GEDCOM object (with only a header and trailer section) and adding records as you would add layers to a ggplot object (but instead using the pipe operator, |>).

An example is below:

```{r example}
library(tidyged)

tg <- gedcom(subm("Jamie Lendrum"), gedcom_description = "The Skywalker family", gedcom_copyright = "None") |>
add_indi(sex = "M", indi_notes = "The central character in the Star Wars Skywalker Saga") |>
add_indi_names(name_pieces(given = "Anakin", surname = "Skywalker"), type = "birth") |>
add_indi_names(name_pieces(prefix = "Darth", given = "Vader"),
type = "given") |>
add_indi(sex = "F", indi_notes = "Queen of Naboo") |>
add_indi_names(name_pieces(given = "Padme", surname = "Amidala"),
type = "birth") |>
add_indi(sex = "F") |>
add_indi_names(name_pieces(given = "Leia", surname = "Skywalker"),
type = "birth") |>
add_indi_names(name_pieces(prefix = "Princess", given = "Leia", surname = "Organa"),
type = "adoptive") |>
add_indi(sex = "M") |>
add_indi_names(name_pieces(given = "Luke", surname = "Skywalker"),
type = "birth") |>
add_indi(sex = "M") |>
add_indi_names(name_pieces(given = "Obi-Wan", nickname = "Ben", surname = "Kenobi"),
type = "birth")

anakin_xref <-find_indi_name(tg, "Anakin")
padme_xref <-find_indi_name(tg, "Padme")
luke_leia_xref <-find_indi_name_all(tg, "Luke|Leia")
obiwan_xref <-find_indi_name(tg, "Obi-Wan")

tg <- tg |>
add_famg(husband = anakin_xref,
wife = padme_xref,
children = luke_leia_xref) |>
activate_indi(anakin_xref) |>
add_indi_association(obiwan_xref, association = "Master") |>
add_indi_fact("death", age = "45y", cause = "Killed by son Luke",
fact_place = place(name = "Second Death Star", notes = "Orbiting Endor System")) |>
add_indi_fact("religion", descriptor = "Jedi") |>
add_indi_fact("possession", descriptor = "Lightsaber") |>
add_note("Based on Star Wars") |>
add_sour(short_title = "Star Wars", title = "Star Wars Episode IV: A New Hope") |>
add_repo("The Skywalker Saga") |>
add_media(file_reference = "XYZ", format = "JPEG")

print(tg, n = Inf)
```

Just like a ggplot object requires aesthetics, a GEDCOM file requires details of a submitter. If no submitter details are given, the username is used.

Within the package, GEDCOM files are represented as a sub-class of tibble known as `tidyged` objects, allowing easy manipulation and exploitation of existing `tidyverse` infrastructure.

A number of functions are available to provide summaries of `tidyged` objects:

```{r}
num_indi(tg)
num_famg(tg)

str(tg)
summary(tg)

df_indi(tg) |> knitr::kable()
df_famg(tg) |> knitr::kable()
```

This package allows limited editing of `tidyged` objects (adding/removing records, as well as the addition of some record substructures). Editing of existing records is made possible through 'activation' (much like the `tidygraph` package). When a record is created, it automatically becomes the active record, through an object attribute. Record editing functions then act on this record. Other records can be activated through a series of `activate_*()` functions.

## References

* [The GEDCOM 5.5.5 Specification](https://www.gedcom.org/gedcom.html)