I am very new to r
and programming, so my knowledge is limited. I am using the igraph
package and tkplot
to make and present a directed acyclic graph. I managed to make a graph and I am trying to figure out how to add labels to each edge. My goal is to have a small annotation on the line between each vertices/vertex explaining their relationship.
I have tried inserting text as shown below:
text(-1, 0,"[1, 2, 3]")
text(0, 1,"[3, 5, 6]")
However, this text does not transfer to out of r
with tkplot
and is hard to line up with the lines between vertices.
this code gave me the exact graph I want minus the text between vertices.
g <- graph.formula("ATB" -+ "Microbiome",
"Microbiome" -+ "Inflammation A" -+ "IO Response",
"Microbiome" -+ "Inflammation B" -+ "IO Response",
"Microbiome" -+ "IO Response",
"ATB" -+ "IO Response",
"Corticosteroids" -+ "IO Response",
"Corticosteroids" -+ "Microbiome",
"PPI" -+ "IO Response",
"PPI" -+ "Microbiome",
"H2B" -+ "IO Response",
"H2B" -+ "Microbiome",
"NSAIDs" -+ "Microbiome",
"NSAIDs" -+ "Inflammation B",
"NSAIDs" -+ "IO Response",
"Corticosteroids" -+ "Inflammation A",
simplify = TRUE)
plot.igraph(g, size = 90)
tkplot(g)