edge list tables code example
Example: edge list tables
library(purrr)
map_df(2:ncol(df), ~select(df, (.x-1):.x) %>% setNames(c("source", "target")), .id="id") %>%
group_by(id) %>%
distinct() %>%
ungroup() %>%
mutate(id = colnames(df)[as.numeric(id)+1])
# A tibble: 9 x 3
# id source target
# <chr> <chr> <chr>
# 1 second A F
# 2 second B F
# 3 second C G
# 4 second D F
# 5 second E G
# 6 second L L
# 7 third F L
# 8 third G L
# 9 third L L