Back to skills
SKILL.md
R Network Analysis
ASecurityR network analysis with igraph, sna. Use for centrality, community detection, and network metrics.
- 5 stars
- 0 votes
- 0 copies
- 1 view
- Added June 4, 2026
Security analysis
100/100Pro scans all 6 files and shows the line behind each finding
npx -y skills add LeoLin990405/r-analytics-skill --skill r-network-analysis --agent claude-codeAre you the author of R Network Analysis?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/leolin990405-r-network-analysis)---
name: r-network-analysis
description: R network analysis with igraph, sna. Use for centrality, community detection, and network metrics.
---
# R Network Analysis
Graph analysis and metrics.
## igraph
```r
library(igraph)
# Create graph
g <- graph_from_data_frame(edges, directed = TRUE, vertices = nodes)
g <- graph_from_adjacency_matrix(adj_matrix)
g <- make_ring(10)
# Basic info
vcount(g); ecount(g)
V(g); E(g)
is_directed(g)
# Centrality
degree(g)
betweenness(g)
closeness(g)
eigen_centrality(g)$vector
page_rank(g)$vector
# Community detection
cluster_louvain(g)
cluster_walktrap(g)
cluster_edge_betweenness(g)
membership(communities)
modularity(communities)
# Paths
shortest_paths(g, from = 1, to = 10)
distances(g)
diameter(g)
# Network metrics
transitivity(g) # Clustering coefficient
graph.density(g)
assortativity_degree(g)
```
## sna
```r
library(sna)
# Centrality
degree(net, cmode = "indegree")
betweenness(net)
closeness(net)
# Structural equivalence
equiv.clust(net)
# QAP correlation
qaptest(list(net1, net2), gcor, g1 = 1, g2 = 2)
```
## Network Statistics
```r
# Degree distribution
degree_distribution(g)
fit_power_law(degree(g))
# Clustering
transitivity(g, type = "local")
transitivity(g, type = "global")
# Components
components(g)
largest_component <- decompose(g)[[1]]
# Motifs
motifs(g, size = 3)
count_motifs(g, size = 3)
```
Files in this skill
- SKILL.md
- igraph/SKILL.md
- network/SKILL.md
- sna/SKILL.md
- statnet/SKILL.md
- tidygraph/SKILL.md
Attribution
Comments
Loading comments…