Hi, all!
I need to calculate local clustering coefficient for a huge bunch of egocentric networks with 1.5 depth. All the files are edgelists named after ego-s, and are stored in 'edgelist' folder. Here is my code to batch import it:
datanames <- as.character(lapply(list.files("./edgelists"), FUN = function(x) strsplit(x, split="\\.")[[1]][1]))
dataset <- lapply(datanames, function(x) list(assign(x, read.table(paste("./edgelists/", x, ".csv", sep=""), header=TRUE, sep=","))))
graphs <- lapply(dataset, function(dataset) graph.data.frame(dataset, directed=F, vertices=NULL))
Now I need to calculate transitivity only for the egos, which names are stored as a chr in 'datanames'.
It seems like I can't use this variable as a value for vids parameter, 1) neither directly, 2) nor after convertion to numeric, double and integer in this function
trans <- lapply(graphs, function(graph) transitivity(graph, type = "local", vids=datanames))
because in the first case it returns the following error:
1) Error in as.igraph.vs(graph, vids) : Invalid vertex names
and after convertion to numeric types I get:
2) Error in .Call("R_igraph_transitivity_local_undirected", graph, vids, :
At iterators.c:759 : Cannot create iterator, invalid vertex id, Invalid vertex id
How can I accomplish my task then?
Thanks in advance,
Alex.
(Social | Network | Data) Analyst
Junior Research Fellow at the International Laboratory of Applied Network Research
National Research University Higher School of Economics