sna

converting data frame into affiliation network in R

一个人想着一个人 提交于 2020-01-02 08:06:42
问题 I have a data frame with the following format: name workplace a A b B c A d C e D .... I would like to convert this data frame into an affiliation network in R with the format A B C D ... a 1 0 0 0 b 0 1 0 0 c 1 0 0 0 d 0 0 1 0 e 0 0 0 1 ... and I used the following program: for (i in 1:nrow(A1)) { a1[rownames(a1) == A1$name[i], colnames(a1) == A1$workplace[i]] <- 1 } where A1 is the data frame, and a1 is the affiliation network. However, since I have a large data frame, the above program

converting data frame into affiliation network in R

こ雲淡風輕ζ 提交于 2020-01-02 08:06:10
问题 I have a data frame with the following format: name workplace a A b B c A d C e D .... I would like to convert this data frame into an affiliation network in R with the format A B C D ... a 1 0 0 0 b 0 1 0 0 c 1 0 0 0 d 0 0 1 0 e 0 0 0 1 ... and I used the following program: for (i in 1:nrow(A1)) { a1[rownames(a1) == A1$name[i], colnames(a1) == A1$workplace[i]] <- 1 } where A1 is the data frame, and a1 is the affiliation network. However, since I have a large data frame, the above program

How to get the details of triads in r/python?

巧了我就是萌 提交于 2019-12-25 03:20:49
问题 I am currently using igraph to get the traid census of a given directed graph using triad_census(g) . This returns the count of triads in each of the 16 classes. e.g., 16 3 0 10 1 0 0 0 0 0 0 0 0 0 0 0 However, I would like to know more details of the triads than these summary statistics. i.e. given that the network has 16 of 003 , what they are? given that the network has 3 012 , what they are? Example: The 3 traids of 012 are (john -> emi, jenne) , (cena -> ally, john) , (emi -> peter,

R - Vertex attributes - 'Inappropriate value given in set.vertex.attribute.'

牧云@^-^@ 提交于 2019-12-24 10:54:15
问题 I have a data.frame containing values I want to use as attributes in a network file. When I try to assign the values as attributes manually half of them work but the other half show this error. I have looked closely at the data and I cannot see anything intrinsic that should be causing this. Format vector input (this one works) visitgo2n%v%"hhid" <- attr2$hhid Here is the error: "Error in set.vertex.attribute(x, attrname = attrname, value = value) : Inappropriate value given in set.vertex

Python 2.7 NetworkX (Make it interactive)

老子叫甜甜 提交于 2019-12-21 12:19:21
问题 I am new to NetworkX. Right now, I manage to connect all the nodes to this particular node. What I want to do next it to make it interactive e.g. able to make each of the node move by dragging using cursor. I know I have to make use of matplotlib, but I am not sure how to use it. Can anyone help me? My codes are: import matplotlib.pyplot as plt import networkx as nx import itertools d = [name of nodes] f = [number per nodes] for i in d: G.add_edge('"' + i + '"',b) pos=nx.fruchterman_reingold

Saving the results of each iteration of a for-loop in R as a network object using the filename

五迷三道 提交于 2019-12-12 03:43:58
问题 I'm attempting to run a loop to iterate through a number of adjacency lists saved as .csv files, convert them to edge lists, and network objects, and save each of these using the filename. The problem is a) the code appears to cycle through the list of filenames but not produce any output b) it won't save the network objects using the filenames (it appears to overwrite each time). Note that the code works fine for an individual file identified by "filename.csv" in replacement of the "f"s in

Transform categorical attribute vector into similarity matrix

此生再无相见时 提交于 2019-12-11 17:37:25
问题 I need to transfrom a categorical attribute vector into a "same attribute matrix" using R. For example I have a vector which reports gender of N people (male = 1, female = 0). I need to convert this vector into a NxN matrix named A (with people names on rows and columns), where each cell Aij has the value of 1 if two persons (i and j) have the same gender and 0 otherwise. Here is an example with 3 persons, first male, second female, third male, which produce this vector: c(1, 0, 1) I want to

Betweenness centrality for relatively large scale data

核能气质少年 提交于 2019-12-11 02:27:14
问题 Using R,I try to calculate Betweenness centrality for about 1 million nodes and more than 20 million edges. To do so I have a pretty decent machine with 128GB ram and 4*2.40GHz CPU and a 64bit windows. Yet, using betweeness() of Igraph takes ages. I am wondering is there any quick solution? would it be faster, if I use Gephi?! 来源: https://stackoverflow.com/questions/21718078/betweenness-centrality-for-relatively-large-scale-data

How to get triad census in undirected graph using networkx in python

a 夏天 提交于 2019-12-08 13:22:15
问题 I have an undirected networkx graph as follows and I want to print triad census of the graph. However, nx.triadic_census(G) does not support undirected graphs. import networkx as nx G = nx.Graph() G.add_edges_from( [('A', 'B'), ('A', 'C'), ('D', 'B'), ('E', 'C'), ('E', 'F'), ('B', 'H'), ('B', 'G'), ('B', 'F'), ('C', 'G')]) Error: NetworkXNotImplemented: not implemented for undirected type I am aware that there is only 4 isomorphic classes for undirected graphs (not 16 as directed graphs). Is

How can I open .net files with package sna in R?

纵然是瞬间 提交于 2019-12-08 12:59:34
问题 I have a lot of .net files, and the package tutorial says it is possible to use this format with sna. My error message is: > Error in FUN(X[[1L]], ...) : as.edgelist.sna input must be an > adjacency matrix/array, edgelist matrix, network, or sparse matrix, or > list thereof. How can I open .net files with sna package in R? I browsed the net but I couldn't find any helpful information to my problem. I have no problem with using package igraph, but there are some pros to use package sna, too.