아래의 문법에서 내가 뭘 잘못하고 있는지 알기 원하십니까? 색상 그라디언트를 사용하여 연속적인 속성 "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]
당신이 colorRampPalette 대신에 필드 패키지에서'two.colors'을하실 수 있습니다. – flies
대단히 감사합니다. 그래, 나는 다른 사람의 예제 구문을 복사하는 것을 배우려고했기 때문에 실수로 텍스트가 아닌 숫자로 속성을 만들었다는 것을 깨달았다. – JRO
허용하는 것을 잊지 마세요;) – flies