When I run this code, it works for about 100 iterations of the for loop then throws this error:Error in seq.default(start.at, NROW(data), by = by) :
wrong sign in 'by' argument
Here is the data that I used, and here is my code...
library(igraph)
library(zoo)
#import network data as edgelist
fake.raw.data <- read.csv("fakedata.csv")
fake.raw.data <- fake.raw.data[,2:3]
as.matrix(fake.raw.data)
#create igraph object from edglist data
fgraph <- graph_from_data_frame(fake.raw.data, directed = TRUE)
#finding the shortest paths that go through "special chain"
POI <- list()
df.vertices <- get.data.frame(fgraph, what = "vertices")
list.vertices <- as.list(df.vertices[,1])
AverageEBForPath <- function(graph = fgraph, from, to, mode = "out", chain){
browser()
asp <- all_shortest_paths(graph, from = from, to = to, mode)$res
for(i in seq_along(asp)){
if(sum(rollapply(names(asp[[i]]), length(chain), identical, chain)) == 1){
print(names(asp[[i]]))
}
}
}
AverageEBForPath(from = 32, to = V(fgraph), chain = c(32, 15, 9))
If anybody could help that would be extremely appreciated. I have been working on this for days, and I am really stuck.