您好,登錄后才能下訂單哦!
如何進(jìn)行R語言網(wǎng)絡(luò)圖的分析,相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。
nodes<-read.csv("Data_files/Dataset1-Media-Example-NODES.csv",
header=T,as.is = T)
links<-read.csv("Data_files/Dataset1-Media-Example-EDGES.csv",
header=T,as.is=T)
nodes
links
dim(nodes)
dim(links)
library(igraph)
net<-graph_from_data_frame(d=links,
vertices=nodes,directed=T)
net
library(ggraph)
ggraph(net)+
geom_edge_link(color="green")+
geom_node_point(color="red",size=10)+
theme_void()
ggraph(net,layout="lgl")+
geom_edge_link()+
theme_void()
ggraph(net,layout="lgl")+
geom_edge_fan()+
geom_node_point(color=V(net),size=8)+
theme_void()
ggraph(net, layout = 'linear') +
geom_edge_arc(color = "orange", width=0.7) +
geom_node_point(size=5, color="gray50") +
theme_void()
ggraph(net, layout="lgl") +
geom_edge_link(aes(color = type)) + # colors by edge type
geom_node_point(aes(size = audience.size)) + # size by audience size
theme_void()
ggraph(net, layout = 'lgl') +
geom_edge_arc(color="gray", curvature=0.3) +
geom_node_point(color="orange", aes(size = audience.size)) +
geom_node_text(aes(label = media), size=2, color="gray50", repel=T) +
theme_void()
教程中的例子可以重復(fù)出來,但是如何準(zhǔn)備自己的數(shù)據(jù)呢?
嘗試模仿
df1<-data.frame(id=c("A","B","C"))
df2<-data.frame(from=c("A","A","B","C"),
to=c("B","C","C","B"),
type=c("hyperlink","hyperlink","mention","mention"),
weight=c(30,10,20,50))
net1<-graph_from_data_frame(d=df2,vertices = nodes)
遇到報(bào)錯(cuò)
Error in graph_from_data_frame(d = df2, vertices = nodes) :
Some vertex names in edge list are not listed in vertex data frame
暫時(shí)還不知道如何解決!
看完上述內(nèi)容,你們掌握如何進(jìn)行R語言網(wǎng)絡(luò)圖的分析的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。