- Joining together: “You might expect to see this data in its own table because it would be easy to join to the characters data as needed.”
characters <- chars |>
unnest_wider(json) |>
select(id, name, gender, culture, born, died, alive)
characters
## # A tibble: 30 × 7
## id name gender culture born died alive
## <int> <chr> <chr> <chr> <chr> <chr> <lgl>
## 1 1022 Theon Greyjoy Male "Ironborn" "In 278 AC or 279 AC,… "" TRUE
## 2 1052 Tyrion Lannister Male "" "In 273 AC, at Caster… "" TRUE
## 3 1074 Victarion Greyjoy Male "Ironborn" "In 268 AC or before,… "" TRUE
## 4 1109 Will Male "" "" "In … FALSE
## 5 1166 Areo Hotah Male "Norvoshi" "In 257 AC or before,… "" TRUE
## 6 1267 Chett Male "" "At Hag's Mire" "In … FALSE
## 7 1295 Cressen Male "" "In 219 AC or 220 AC" "In … FALSE
## 8 130 Arianne Martell Female "Dornish" "In 276 AC, at Sunspe… "" TRUE
## 9 1303 Daenerys Targaryen Female "Valyrian" "In 284 AC, at Dragon… "" TRUE
## 10 1319 Davos Seaworth Male "Westeros" "In 260 AC or before,… "" TRUE
## # ℹ 20 more rows
characters |>
left_join(titles, join_by(id)) |>
left_join(aliases, join_by(id)) |>
left_join(allegiances, join_by(id)) |>
left_join(books, join_by(id)) |>
left_join(tvSeries, join_by(id))
## Warning in left_join(left_join(characters, titles, join_by(id)), aliases, : Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 1 of `x` matches multiple rows in `y`.
## ℹ Row 1 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
## "many-to-many"` to silence this warning.
## Warning in left_join(left_join(left_join(characters, titles, join_by(id)), : Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 93 of `x` matches multiple rows in `y`.
## ℹ Row 1 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
## "many-to-many"` to silence this warning.
## Warning in left_join(left_join(left_join(left_join(characters, titles, join_by(id)), : Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 1 of `x` matches multiple rows in `y`.
## ℹ Row 1 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
## "many-to-many"` to silence this warning.
## Warning in left_join(left_join(left_join(left_join(left_join(characters, : Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 1 of `x` matches multiple rows in `y`.
## ℹ Row 1 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
## "many-to-many"` to silence this warning.
## # A tibble: 2,507 × 12
## id name gender culture born died alive titles aliases allegiances books
## <int> <chr> <chr> <chr> <chr> <chr> <lgl> <chr> <chr> <chr> <chr>
## 1 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A Ga…
## 2 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A Ga…
## 3 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A Ga…
## 4 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A Ga…
## 5 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A Ga…
## 6 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A Ga…
## 7 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A St…
## 8 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A St…
## 9 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A St…
## 10 1022 Theo… Male Ironbo… In 2… "" TRUE Princ… Prince… House Grey… A St…
## # ℹ 2,497 more rows
## # ℹ 1 more variable: tvSeries <chr>