igraph - How to compress rows to a binary list in R? -
i have list of page visits session id. need modify list of 2 pages each, repeating across list until used. id duplicated down new rows. need keep prior node go new one.
i want turn this:
session page id1 home id1 inventory id1 details id1 home id2 inventory id2 home id2 details id2 inventory id3 inventory id3 details id4 details id4 inventory id4 details id4 inventory id4 details id4 inventory id4 details id4 inventory id4 home
into this:
session node1 node2 id1 home inventory id1 inventory vehicles id1 vehicle home id2 inventory home id2 home vehicle id2 vehicle inventory id3 inventory vehicle id4 vehicle inventory id4 inventory vehicle id4 vehicle inventory id4 inventory vehicle id4 vehicle inventory id4 inventory vehicle id4 vehicle inventory id4 inventory home
the ultimate goal feed igraph network diagram of activity. there can many 44 different page visits in session if meaningful.
assuming vehicle details, , data stored in mydata
library(data.table) setdt(mydata) mydata[, node2 := page[.i + 1]] mydata[, t := session[.i + 1]] mydata[session == t, list(session,node1 = page,node2)]
Comments
Post a Comment