library(tricky)
library(tibble)
Suppose we have a dataset with for each row the name of a node and the name of a group it belongs to. We want to have a dataset with all relationships between nodes (ie if A and B belong to the group a, they have one relationship.)
make_single_node_node_table_
makes a table with one row for each relationship for a single node.make_node_node_table_
makes a table with one row for each relationship for all nodestoy_data <- tibble::tibble(
node = c("A", "B", "C", "A", "B"),
link = c("a", "a", "b", "b", "b")
)
toy_data
## # A tibble: 5 x 2
## node link
## <chr> <chr>
## 1 A a
## 2 B a
## 3 C b
## 4 A b
## 5 B b
library(tricky)
make_single_node_node_table_(
.data = toy_data,
.id = "A",
node = "node",
link = "link"
)
## # A tibble: 3 x 2
## node_A node_B
## <chr> <chr>
## 1 A B
## 2 A C
## 3 A B
library(tricky)
make_node_node_table_(
.data = toy_data,
node = "node",
link = "link"
)
## node_A node_B
## 1 A B
## 2 A C
## 3 A B
## 4 B A
## 5 B C
## 6 B A
## 7 C A
## 8 C B