-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
97 lines (70 loc) · 3.09 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
output:
github_document:
toc: false
fig_width: 10.08
fig_height: 6
vignette: >
%\VignetteIndexEntry{README}
\usepackage[utf8]{inputenc}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
chunk_output_type: console
---
# tidyfamily
```{r, echo = FALSE, warning=FALSE, message=FALSE}
library(ggplot2)
library(dplyr)
knitr::opts_chunk$set(
collapse = TRUE,
# fig.path = "man/figures/",
dpi = 450
)
# https://github.com/adrienverge/familytreemaker
```
A little package to create family dynasties and visualize them as networks and genealogical trees.
## Current Problems / Features ideas
- Don't know how to nicely display them as trees (help by answering [**here**](https://stackoverflow.com/questions/67102965/organize-graph-nodes-vertically-according-to-a-y-value-in-r-ggraph))
- Functions to retrieve family members of a given degree
## Installation
```{r eval=FALSE}
remotes::install_github("DominiqueMakowski/tidyfamily")
library(tidyfamily)
```
## Create Family Data
```{r, eval = FALSE}
library(tidyfamily)
library(dplyr)
# Louis XIV's unit
data <- family_member("Louis XIV", birth = "1638-09-05", death = "1715-09-01", sex = "Male") %>%
family_member("Marie-Thérèse d'Autriche", birth = "1638-10-10", death = "1683-07-30", sex = "Female") %>%
family_son("Louis1661", name = "Louis de France", birth = "1661-11-01", death = "1711-04-14", father = "Louis XIV", mother = "Marie-Thérèse d'Autriche") %>%
family_daughter("Marie-Thérèse de France", text = "La Petite Madame", birth = 1667, death = 1672, father = "Louis XIV", mother = "Marie-Thérèse d'Autriche") %>%
family_son("Philippe-Charles de France", text = "Duc d'Anjou", birth="1668-08-05", death = "1671-07-10", father = "Louis XIV", mother = "Marie-Thérèse d'Autriche") %>%
# Louis1661's unit
family_member("Marie Anne Christine de Bavière", birth = 1660, sex = "Female") %>%
family_son("Louis1682", name = "Louis de France", text = "Duc de Bourgogne", birth=1682, death = 1712, father = "Louis1661", mother = "Marie Anne Christine de Bavière") %>%
family_son("Philippe V", name = "Philippe V d'Espagne", birth=1683, death = 1746, father = "Louis1661", mother = "Marie Anne Christine de Bavière") %>%
family_son("Charles", birth="1686-07-31", father = "Louis1661", mother = "Marie Anne Christine de Bavière") %>%
# Louis1682's unit
family_member("Marie-Adélaïde de Savoie", birth = "1685-12-06", death = "1712-02-12", sex = "Female") %>%
family_son("Louis XV", birth = "1710-02-15", death = "1774-05-10", father = "Louis1682", mother = "Marie-Adélaïde de Savoie")
data
```
```{r echo=FALSE, message=FALSE, warning=FALSE}
library(tidyfamily)
knitr::kable(head(dynasty_capetian()))
```
## Visualize Family Tree
```{r message=FALSE, warning=FALSE}
library(ggraph)
library(tidygraph)
data <- dynasty_capetian()
# edges <- tidyfamily:::.family_get_edges(data)
# nodes <- tidyfamily:::.family_get_nodes(data)
tidyfamily::family_graph(data) %>%
ggraph(layout = "nicely") +
geom_edge_link(aes(color = link), arrow = arrow()) +
geom_node_label(aes(label = label)) +
ggraph::theme_graph()
```