-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
64 lines (64 loc) · 2.48 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
knitr::opts_chunk$set(echo = TRUE)
#install.packages("tidygraph")
#install.packages("ggraph")
#devtools::install_github('thomasp85/ggraph') #only for newest insights, and not for today;)
library(tidygraph)
library(tidyverse)
library(ggraph)
library(ggplot2)
nodes <- read.csv("https://kateto.net/workshops/data/Dataset1-Media-Example-NODES.csv", header=T, as.is=T)
edges <- read.csv("https://kateto.net/workshops/data/Dataset1-Media-Example-EDGES.csv", header=T, as.is=T)
head(nodes)
head(edges)
### your code
### plot()
### your code
### your code
### your code
### your code
# ggraph(news_media) +
# geom_edge_link(color=...) + geom_node_text(aes(label =...), repel=TRUE)+ #geom_node_point()
### your code
ggraph(news_media, layout='linear') +
geom_edge_arc(color="gray") + geom_node_text(aes(label = media), repel=TRUE)+ geom_node_point()
knitr::opts_chunk$set(echo = TRUE)
#install.packages("tidygraph")
#install.packages("ggraph")
#devtools::install_github('thomasp85/ggraph') #only for newest insights, and not for today;)
library(tidygraph)
library(tidyverse)
library(ggraph)
library(ggplot2)
nodes <- read.csv("https://kateto.net/workshops/data/Dataset1-Media-Example-NODES.csv", header=T, as.is=T)
edges <- read.csv("https://kateto.net/workshops/data/Dataset1-Media-Example-EDGES.csv", header=T, as.is=T)
head(nodes)
head(edges)
news_media<-tbl_graph(nodes,edges)
news_media
plot(news_media)
media_hyper<-news_media %>% activate(edges) %>% filter(type=="hyperlink")
media_hyper
plot(media_hyper)
media_mention <- news_media %>% activate(edges) %>% filter(type=="mention")
media_mention
plot(media_mention)
media_mention %>% graph_join(media_hyper) %>% plot()
media_reversed<-news_media %>% activate(edges)%>%reroute(from = to, to = from)
plot(media_reversed)
ggraph(news_media) +
geom_edge_link(color="gray") + geom_node_text(aes(label = media), repel=TRUE) + geom_node_point()
ggraph(news_media) +
geom_edge_link(aes(color = type)) +
geom_node_text(aes(label = media))
ggraph(news_media, layout='linear') +
geom_edge_arc(color="gray") + geom_node_text(aes(label = media), repel=TRUE)+ geom_node_point()
ggraph(news_media) +
geom_edge_link(aes(alpha = weight)) +
geom_node_text(aes(label = media))
news_media%>% activate(nodes) %>%
mutate(centrality = centrality_degree()) %>% arrange(centrality)
news_media%>% activate(nodes) %>%
mutate(centrality = centrality_degree())%>% arrange(centrality)%>%
ggraph() +
geom_edge_link() +
geom_node_point(aes(size = centrality, colour = centrality))+ geom_node_text(aes(label = media))