Skip to content

Discuss how to remove attributes #2835

Description

@maelle

From #2006

 library(igraph)

  g <- make_ring(5)
  V(g)$color <- "red"

  # what a user might try, expecting it to remove the attribute (like df$col <- NULL)
  V(g)$color <- NULL
  V(g)$color

  # the actual current way to remove a vertex attribute
  g <- delete_vertex_attr(g, "color")
  V(g)$color

On the stoop2 branch: V(g)$color <- NULL silently does nothing (still prints "red" "red" "red" "red"
"red"), while delete_vertex_attr(g, "color") correctly removes it (V(g)$color then errors with "color" is
not a graph attribute, or similar — since the attribute no longer exists).

I wonder whether using <- NULL should become possible (instead of just erroring).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions