Skip to content
Back to skills

R Network

ASecurity

R network analysis packages. Use for graph analysis, social network analysis, network visualization, and community detection.

  • 5 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added June 4, 2026
datanodegitapi

Works with

  • api

Security analysis

A100/100

Pro scans all 16 files and shows the line behind each finding

Scanned June 4, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill r-network --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of R Network?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for R Network
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-r-network/badge)](https://www.skillsdirectory.com/skills/leolin990405-r-network)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: r-network
description: R network analysis packages. Use for graph analysis, social network analysis, network visualization, and community detection.
---

# R Network Analysis Skill

## Sub-skills

| Sub-skill | Description |
|-----------|-------------|
| [r-network-analysis](r-network-analysis/SKILL.md) | igraph, tidygraph, centrality, communities |
| [r-network-viz](r-network-viz/SKILL.md) | ggraph, visNetwork, networkD3 |
| [r-network-dynamic](r-network-dynamic/SKILL.md) | networkDynamic, ndtv, temporal networks |

Network and graph analysis in R.

## Core Packages

| Package | Description |
|---------|-------------|
| **igraph** ★ | Comprehensive network analysis |
| **tidygraph** ★ | Tidy API for graphs |
| **network** | Basic relational data tools |
| **sna** | Social network analysis |

## Network Modeling

| Package | Description |
|---------|-------------|
| **ergm** | Exponential random graph models |
| **latentnet** | Latent position/cluster models |
| **manynet** | Many network types |

## Dynamic Networks

| Package | Description |
|---------|-------------|
| **networkDynamic** | Dynamic/temporal networks |
| **ndtv** | Animated network visualization |
| **netdiffuseR** | Network diffusion analysis |

## Visualization

| Package | Description |
|---------|-------------|
| **ggraph** ★ | Grammar of graphics for graphs |
| **visNetwork** ★ | Interactive visualization (vis.js) |
| **networkD3** | D3 network graphs |
| **autograph** | Automagic network plotting |

## Metrics & Analysis

| Package | Description |
|---------|-------------|
| **tnet** | Weighted/two-mode networks |
| **rgexf** | Export to GEXF (Gephi) |

## Quick Examples

```r
# igraph basics
library(igraph)

# Create graph
g <- graph_from_data_frame(edges, directed = TRUE, vertices = nodes)
# Or from adjacency matrix
g <- graph_from_adjacency_matrix(adj_matrix)

# Basic metrics
vcount(g)  # Number of vertices
ecount(g)  # Number of edges
degree(g)  # Degree centrality
betweenness(g)  # Betweenness centrality
closeness(g)  # Closeness centrality
page_rank(g)$vector  # PageRank

# Community detection
communities <- cluster_louvain(g)
membership(communities)
modularity(communities)

# Shortest paths
shortest_paths(g, from = "A", to = "B")
distances(g)

# Plot
plot(g,
     vertex.size = degree(g) * 2,
     vertex.color = membership(communities),
     edge.arrow.size = 0.5)

# tidygraph + ggraph
library(tidygraph)
library(ggraph)

tg <- as_tbl_graph(g) %>%
  activate(nodes) %>%
  mutate(
    centrality = centrality_degree(),
    community = group_louvain()
  )

ggraph(tg, layout = "fr") +
  geom_edge_link(alpha = 0.5) +
  geom_node_point(aes(size = centrality, color = factor(community))) +
  geom_node_text(aes(label = name), repel = TRUE) +
  theme_graph()

# Interactive visualization
library(visNetwork)
visNetwork(nodes, edges) %>%
  visOptions(highlightNearest = TRUE) %>%
  visLayout(randomSeed = 123)

# Network statistics
transitivity(g)  # Clustering coefficient
diameter(g)  # Network diameter
graph.density(g)  # Density
assortativity_degree(g)  # Degree assortativity
```

## Common Workflows

### Social Network Analysis
```r
library(igraph)

# Load data
edges <- read.csv("edges.csv")
nodes <- read.csv("nodes.csv")
g <- graph_from_data_frame(edges, vertices = nodes)

# Centrality analysis
nodes$degree <- degree(g)
nodes$betweenness <- betweenness(g)
nodes$eigenvector <- eigen_centrality(g)$vector

# Community detection
comm <- cluster_louvain(g)
nodes$community <- membership(comm)

# Key players
head(nodes[order(-nodes$betweenness), ])
```

### Network Visualization
```r
library(ggraph)
library(tidygraph)

tg <- as_tbl_graph(g) %>%
  activate(nodes) %>%
  mutate(importance = centrality_pagerank())

# Force-directed layout
ggraph(tg, layout = "fr") +
  geom_edge_link(aes(alpha = weight)) +
  geom_node_point(aes(size = importance)) +
  theme_void()

# Circular layout by community
ggraph(tg, layout = "linear", circular = TRUE) +
  geom_edge_arc(aes(alpha = weight)) +
  geom_node_point(aes(color = factor(community))) +
  coord_fixed()
```

## Resources

- igraph: https://igraph.org/r/
- tidygraph: https://tidygraph.data-imaginist.com/
- ggraph: https://ggraph.data-imaginist.com/
- visNetwork: https://datastorm-open.github.io/visNetwork/

Files in this skill

  • SKILL.md4.2 KB
  • r-network-analysis/SKILL.md1.3 KB
  • r-network-analysis/igraph/SKILL.md3.3 KB
  • r-network-analysis/network/SKILL.md3.2 KB
  • r-network-analysis/sna/SKILL.md1.4 KB
  • r-network-analysis/statnet/SKILL.md3.5 KB
  • r-network-analysis/tidygraph/SKILL.md1.7 KB
  • r-network-dynamic/SKILL.md1.3 KB
  • r-network-dynamic/ndtv/SKILL.md1.9 KB
  • r-network-dynamic/networkDynamic/SKILL.md1.9 KB
  • r-network-dynamic/tsna/SKILL.md1.7 KB
  • r-network-viz/SKILL.md1.6 KB
  • r-network-viz/ggraph/SKILL.md1.9 KB
  • sub-skills/r-network-analysis/sub-skills/sna/SKILL.md1.4 KB
  • sub-skills/r-network-analysis/sub-skills/tidygraph/SKILL.md1.7 KB
  • sub-skills/r-network-viz/sub-skills/ggraph/SKILL.md1.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in data →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.