I'm trying to remove all vertices from a graph which have the value "NA" in the attribute "concreteness". I've tried using the following code:
G.concrete <- delete.vertices(g, V(g)$concreteness[V(g)$concreteness, value = "NA"])
but no luck.
For example if we take the concreteness values to be:
concreteness <- c(NA, 0.1, 0.2, 0.3, 0.4, NA, 0.4, 0.3, 0.2, 0.1)
And then set them as attributes using:
g <- make_ring(10) %>%
set_vertex_attr("concreteness", value = concreteness)
We would have two vertices which would need to be removed. These "NA"
values register as "TRUE"
when queried using is.na()
.
Thanks,
Peter
question from:
https://stackoverflow.com/questions/65913633/r-igraph-remove-vertices-with-attribute-value-na 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…