Any idea what I'm doing wrong in the below syntax? I'm trying to colour my nodes by the continuous attribute "EM" using a colour gradient. After the last command i get the error:
Error in palf[V(g)$EM] : object of type 'closure' is not subsettable
I don't know what this means.
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]