What Are Social Networks?: James Curley
What Are Social Networks?: James Curley
Analysis in R
NETWORK ANALYSIS IN R
James Curley
Associate Professor,
University of Texas at Austin
DataCamp Network Analysis in R
g <- graph.edgelist(as.matrix(df),
directed = FALSE)
IGRAPH UN-- 7 7 --
+ attr: name (v/c)
+ edges (vertex names):
[1] A--B A--C A--D A--E A--F E--F
DataCamp Network Analysis in R
igraph objects
V(g) plot(g)
+ 7/7 vertices, named:
[1] A B C D E F G
E(g)
+ 7/7 edges (vertex names):
[1] A--B A--C A--D A--E A--F E--F
gorder(g)
[1] 7
gsize(g)
[1] 7
DataCamp Network Analysis in R
NETWORK ANALYSIS IN R
Let's practice!
DataCamp Network Analysis in R
NETWORK ANALYSIS IN R
Network attributes
James Curley
Associate Professor,
University of Texas at Austin
DataCamp Network Analysis in R
Vertex Attributes
g
IGRAPH UN-- 7 7 --
+ attr: name (v/c)
+ edges (vertex names):
[1] A--B A--C A--D A--E A--F E--F F--G
DataCamp Network Analysis in R
Edge Attributes
DataCamp Network Analysis in R
Adding Attribtues I
vertex_attr(g)
edge_attr(g)
$name
[1] "A" "B" "C" "D" "E" "F" "G" $frequency
[1] 2 1 1 1 3 2 4
$age
[1] 20 25 21 23 24 23 22
DataCamp Network Analysis in R
Adding attributes II
Subsetting Networks
E(g)[[inc('E')]]
E(g)[[frequency>=3]]
Network Visualization
V(g)$color <- ifelse(
V(g)$age > 22, "red", "white"
)
NETWORK ANALYSIS IN R
Let's practice!
DataCamp Network Analysis in R
NETWORK ANALYSIS IN R
Network Visualization
James Curley
Associate Professor,
University of Texas at Austin
DataCamp Network Analysis in R
DataCamp Network Analysis in R
igraph Layouts
NETWORK ANALYSIS IN R
Let's practice!