[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] error plotting A graph with attributes example
From: |
Jarrett Byrnes |
Subject: |
[igraph] error plotting A graph with attributes example |
Date: |
Sat, 3 Mar 2007 13:57:13 -0800 |
Hey, all, I'm trying to figure out igraph for my own uses, and ran
through the A graph with attributes example at http://
cneurocvs.rmki.kfki.hu/igraphbook/igraphbook-creating.html#id2569368
which uses the from http://cneurocvs.rmki.kfki.hu/igraphbook/import.R
(which I will place at the end of the email).
The problem is that, when I attempt to plot it, as specified in the
tutorial, with
E(g)$color <- "black"
E(g)[ room=="y" ]$color <- "red"
tkplot(g, layout=layout.kamada.kawai, edge.color=E(g)$color)
I get the following error:
Error in from + 1 : non-numeric argument to binary operator
What does this error mean? What is the problem and fix, as I have an
example that works more or less just like this, and would like to use
similar code.
Thanks!
-Jarrett
p.s. The code from the the example is:
# Read the files first
traits <- read.csv("traits.csv", head=FALSE)
rel <- read.csv("relations.csv", head=FALSE)
# Create the graph, add the vertices
library(igraph)
g <- graph.empty()
g <- add.vertices(g, nrow(traits),
name=as.character(traits[,1]), age=traits[,2],
gender=as.character(traits[,3]))
# Extract first names from the full names
names <- sapply(strsplit(V(g)$name, " "), "[",1)
ids <- 1:length(names)-1
names(ids) <- names
# Create the edges
from <- as.character(rel[,1])
to <- as.character(rel[,2])
edges <- matrix(c(ids[from], ids[to]), nc=2)
# Add the edges
g <- add.edges(g, t(edges),
room=as.character(rel[,3]),
friend=rel[,4], advice=rel[,5])
#plot it
E(g)$color <- "black"
E(g)[ room=="y" ]$color <- "red"
tkplot(g, layout=layout.kamada.kawai, edge.color=E(g)$color)
- [igraph] error plotting A graph with attributes example,
Jarrett Byrnes <=