Irgendeine Idee, was ich falsch in der folgenden Syntax mache? Ich versuche, meine Knoten durch das kontinuierliche Attribut "EM" mit einem Farbverlauf zu färben. Nach dem letzten Befehl erhalte ich die Fehlermeldung:igraph: Färben von Knoten durch kontinuierliche Attributvektor
Error in palf[V(g)$EM] : object of type 'closure' is not subsettable
Ich weiß nicht, was das bedeutet.
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]
Sie können 'two.colors' aus den Bereichen Paket anstelle von colorRampPalette. – flies
vielen dank, das hat funktioniert! Ja, ich erkannte, dass ich das Attribut numerisch und nicht irrtümlich gemacht hatte, da ich versuchte, durch das Kopieren der Beispiel-Syntax einer anderen Person – JRO
zu lernen. – flies