This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Set multiple attributes to one node in R

I am using igraph to construct a networks. But I have a doubt, I have nodes with 3 different attributes (On, Off and Unknown). For example:

N1  ON
N1  OFF
N2  UNKNOWN
N2  ON
N2  OFF

How can I set the three different attributes in the same node?

r igraph

Something like this ?

library(igraph)
df=read.table("bio.txt", header=FALSE)
g=graph_from_data_frame(df)
plot(g)

Check igraph docs to modify network.

I don't think this answer the question. As I understand it, OP wants to have multiple values as an attribute.

I was also little skeptical about my understanding about the question (hence the ?).

1 answer

You can use a vector as an attribute, something like:

g <- set.vertex.attribute(g, 'status', "N2", list(c("ON", "OFF", "UNKNOWN")))

This is exactly what I was looking for. Thank you so much and sorry for my bad redaction, I am new in this site.

Log in to answer this question.