Skip to content

Instantly share code, notes, and snippets.

@alexbrey
alexbrey / project.R
Last active August 10, 2016 02:11 — forked from mdlincoln/project.R
Maintain other attributes when making a bipartite projection
library(igraph)
library(dplyr)
# Assume you have a dataframe "objects" with columns "object_id", "artist_id", "date"
# Create an identical table that just gives a new variable name to "artist_id"
flipped_objects <- objects %>% rename(artist2_id = artist_id)
# Join the tables together (essentially joining objects to itself, creating every combination
# of artist that share an object_id and date
edges <- objects %>%