sabih4911
sabih4911

Reputation: 1

Adding specific id attribute as labels in graph in igraph

I need to add the id attribute to my vertices as labels, and display them in the plot. Which I did with the following code:

V(novel)$label <- V(novel)$id
plot(novel)

However, I only want to display the id of the vertices where the weighted degree is more than 30. I tried the code below, but it gives me only TRUE or FALSE as output, instead of filtering the vertices.

graph.strength(novel) > 30

How can I filter in which vertices should the plot display the id?

Upvotes: 0

Views: 468

Answers (1)

Tam&#225;s
Tam&#225;s

Reputation: 48071

V(novel)$label <- ifelse(graph.strength(novel) > 30, V(novel)$id, "") should do the trick; basically you set up an empty label for those vertices that have a strength less than or equal to 30.

Upvotes: 1

Related Questions