identify groups of linked episodes which chain together
The Bioconductor package RBGL (an R interface to the BOOST graph library) contains a function, connectedComp(), which identifies the connected components in a graph — just what you are wanting. (To use the function, you will first need to install the graph and RBGL packages, available here and here.) library(RBGL) test <- data.frame(id1=c(10,10,1,1,24,8),id2=c(1,36,24,45,300,11)) ## Convert … Read more