1
如何绘制R中的条形图并使用特定节点的特定属性? 我有一个GML文件是这样的:如何在R中绘制节点属性的条形图
graph [
node [
id 0
label "Apple"
year 1997
bold 1
normal 4
light 15
]
node [
id 1
label "Apple"
year 2000
bold 2
normal 16
light 2
]
node [
id 2
label "BBC"
year 2010
bold 18
normal 2
light 0
]
]
和我运行该R脚本,我有麻烦时,我需要提取从一个节点选择的属性值:
install.packages(c("igraph"))
library(igraph)
g = read.graph(file = "/media/Data/TEMP/R_test/test.gml", format = "gml")
apple = V(g)$label[V(g)$label == "Apple"]
table(apple)
for(i in seq(along=apple)){
mL = apple[,i]$bold
L = apple[,i]$normal
pL = apple[,i]$light
barplot(????)
}
我怎么能解决这个问题?脚本THX
THX,我怎么能设置数据绘制一个** Stacked Bar **,就像每年在同一列中的属性[粗体,正常,轻]一样?我需要创建一个表格? – goodguyAbaddon
例如'df < - subset(as_data_frame(g,“vertices”),label ==“Apple”,c(year,bold,normal,light)); barplot(as.matrix(t(df [,-1])),names.arg = df $ year,main =“Apple”)'。 – lukeA