1
任何想法我在做什麼錯誤在下面的語法?我試圖通過使用顏色漸變的連續屬性「EM」對我的節點着色。在最後一個命令後我得到錯誤:igraph:連續屬性向量的着色節點
Error in palf[V(g)$EM] : object of type 'closure' is not subsettable
我不知道這是什麼意思。
library(igraph) # This loads the igraph package
dat=read.csv(file.choose(),header=TRUE,row.names=1,check.names=FALSE) # choose an adjacency matrix from a .csv file
m=as.matrix(dat) # coerces the data set as a matrix
g=graph.adjacency(m,mode="undirected",weighted=NULL) # this will create an 'igraph object'
a=read.csv(file.choose())
V(g)$EM=as.character(a$EM[match(V(g)$name,a$ID)]) # This code says to create a vertex attribute called "EM" by extracting the value of the column "EM" in the attributes file when the ID number matches the vertex name.
V(g)$EM # This will print the new vertex attribute, "EM"
palf <- colorRampPalette(c("gray80", "dark red"))
V(g)$color <- palf[V(g)$EM]
你可能想從田間地頭包'two.colors'到位colorRampPalette的。 – flies
非常感謝你,這工作!是的,我意識到我已經制作了屬性數字而不是錯誤的文本,因爲我試圖從複製別人的示例語法中學習 – JRO
不要忘記標記爲已接受;) – flies