Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- g <- graph.data.frame(Data, directed="TRUE")
- dg <- decompose.graph(g)
- topo <- topological.sort(dg[[1]],mode="out")
- df <- ldply(topo, data.frame)
- colnames(df) <- c("id","id_order")
- df$activity_order <- seq.int(nrow(df))
- ## id id_order activity_order
- ## 1 355 1 1
- ## 2 3180 3 2
- ## 3 6019 4 3
- ## 4 10672 2 4
- ## 5 49507 5 5
- Newdata <- do.call("rbind", lapply(1:clusters(g)$no, function(x){
- dgpart <- dg[[x]]
- topopart <- topological.sort(dgpart,mode="out")
- dfpart <- ldply(topopart, data.frame)
- colnames(dfpart) <- c("id","id_order")
- dfpart$activity_order <- seq.int(nrow(dfpart))
- }))
Add Comment
Please, Sign In to add comment