igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] using variables to call a graph


From: Gábor Csárdi
Subject: Re: [igraph] using variables to call a graph
Date: Fri, 16 Jan 2015 09:44:15 -0500

Hi, it would really help to have a complete, reproducible example. Or at least the complete code. 

If you really have the names of the objects in `nets`, that won't work this way. I could help you make it work, but it is actually bad practice to store names of objects instead of storing the objects themselves.

Put the networks themselves in a list, (see ?list), and then in your loop do 
g <- nets[[i]]

Btw. 1:length(nets) is bad practice, too. It fails if the list/vector is empty. Might not be an issue in your case, but still, it is better to get used to writing seq_along(nets) instead.

Gabor

On Fri, Jan 16, 2015 at 9:14 AM, Luca Rossi <address@hidden> wrote:
Hello,

I’m trying to perform a very simple task but for some reason I can’t understand what I’m doing wrong.
So forgive me if this is very simple.
I need to perform the same analysis on a rather large set of networks but.
I’ve got all the names of the networks in a vector so I was hoping to do this through a simple loop:

for (i in 1:length(nets))
{
   g <- nets[i]
V(g)$ownhiv[is.na(V(g)$ownhiv)] <- 0

[…]
}

But I’ve got an error since: Error in V(`*tmp*`) : Not a graph object

What am I doing wrong?

Thanks a lot

Luca



_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help


reply via email to

[Prev in Thread] Current Thread [Next in Thread]