Rows: 251 Columns: 7
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): case, court, jurisdiction, categories, outcome
dbl (1): year
lgl (1): fair_use_found
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 251 Columns: 9
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (9): title, case_number, year, court, key_facts, issue, holding, tags, o...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# A tibble: 516 × 3
case categories n_category
<chr> <chr> <int>
1 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022) Education… 56
2 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022) Photograph 56
3 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. M… Painting/… 31
4 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. M… Photograph 56
5 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No… Film/audi… 59
6 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No… Music 25
7 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No… Parody/sa… 33
8 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No… Review/co… 41
9 Am. Soc'y for Testing & Materials v. Public.Resource.O… Education… 56
10 Am. Soc'y for Testing & Materials v. Public.Resource.O… Textual w… 93
# ℹ 506 more rows
I want to create a graph where the nodes are categories of case and edges indicate that the categories appear together in a case. To start with we need nodes with IDs:
# A tibble: 516 × 2
case id
<chr> <int>
1 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022) 2
2 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022) 10
3 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. May 31, 2022) 8
4 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. May 31, 2022) 10
5 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-7470-LTS… 3
6 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-7470-LTS… 6
7 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-7470-LTS… 9
8 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-7470-LTS… 11
9 Am. Soc'y for Testing & Materials v. Public.Resource.Org, Inc., No. 13… 2
10 Am. Soc'y for Testing & Materials v. Public.Resource.Org, Inc., No. 13… 12
# ℹ 506 more rows
Now we can inner_join() this object with itself to create all the shared categories. The filter(id.x != id.y) line removes all “loops” from the graph - ie categories connected with themselves.
Warning in inner_join(., categories_to_cases, by = "case"): 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.
edges_categories
# A tibble: 818 × 3
from to case
<int> <int> <chr>
1 2 10 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022)
2 10 2 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022)
3 8 10 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. May 31, 202…
4 10 8 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. May 31, 202…
5 3 6 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
6 3 9 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
7 3 11 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
8 6 3 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
9 6 9 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
10 6 11 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
# ℹ 808 more rows
This list of edges contains duplicates, that’s important when proceeding to create a graph.
Creating a function
case_categories
# A tibble: 516 × 3
case categories n_category
<chr> <chr> <int>
1 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022) Education… 56
2 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022) Photograph 56
3 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. M… Painting/… 31
4 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. M… Photograph 56
5 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No… Film/audi… 59
6 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No… Music 25
7 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No… Parody/sa… 33
8 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No… Review/co… 41
9 Am. Soc'y for Testing & Materials v. Public.Resource.O… Education… 56
10 Am. Soc'y for Testing & Materials v. Public.Resource.O… Textual w… 93
# ℹ 506 more rows
Warning in inner_join(., grouped_by_nodes, by = rlang::as_name(rlang::enquo(grouping_col))): 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: 818 × 3
from to case
<int> <int> <chr>
1 2 10 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022)
2 10 2 De Fontbrune v. Wofsy, 39 F.4th 1214 (9th Cir. 2022)
3 8 10 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. May 31, 202…
4 10 8 Sedlik v. Von Drachenberg, No. CV 21-1102 (C.D. Cal. May 31, 202…
5 3 6 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
6 3 9 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
7 3 11 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
8 6 3 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
9 6 9 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
10 6 11 Sketchworks Indus. Strength Comedy, Inc. v. Jacobs, No. 19-CV-74…
# ℹ 808 more rows