Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206473

How ton extract both node names and their eigenvector centralities in a datatable

$
0
0

I need to create a datatable with both node names and their eigenvector centralities but the problem is that I cannot extract the node names and I use:

#CENTRALITY
library(igraph)
library(magrittr)
library(visNetwork)
library(data.table)
#Load dataset
data(lesmis)

#Nodes
nodes <- as.data.frame(lesmis[2])
colnames(nodes) <- c("id", "label")

#id has to be the same like from and to columns in edges
nodes$id <- nodes$label

#Edges
edges <- as.data.frame(lesmis[1])
colnames(edges) <- c("from", "to", "width")


#Create graph for Louvain
graph <- graph_from_data_frame(edges, directed = FALSE)

graph <- simplify(graph)

library(DT)
ev<-evcent(graph)$vector
datatable(ev)

Viewing all articles
Browse latest Browse all 206473

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>