Skip to content

Duplicate Column Names when Calling ggraph() #208

Description

@billdenney

This appears to be distinct from #138 (because I just installed the github versions of ggraph and tidygraph).

I get this error:

Error: `data` must be uniquely named but has duplicate columns
Call `rlang::last_error()` to see a backtrace

When I try to generate this graph.

library(tidygraph)
library(ggraph)
library(tidyverse)

model_diagram <-
  create_empty(n=0, directed=TRUE) %>%
  bind_nodes(
    data.frame(new=c("D"=1, "PK"=2, "PK_elim"=3, "M"=4, "M_in"=5, "M_in_node"=6, "M_out"=7), stringsAsFactors=FALSE)
  ) %>%
  bind_edges(
    data.frame(
      from=c("D"=1 , "PK"=2     , "PK"=2       , "M_in"=5     , "M_in_node"=6, "M"=4),
      to=  c("PK"=2, "PK_elim"=3, "M_in_node"=6, "M_in_node"=6, "M"=4        , "M_out"=7),
      stringsAsFactors=FALSE
    )
  )

model_layout <-
  create_layout(
    graph=model_diagram,
    layout="manual",
    x=c(1, 1, 1, 2, 2, 2, 2),
    y=-c(1, 2, 3, 1, 2, 3, 4)
  )

ggraph(
  graph=model_diagram,
  layout=model_layout
) +
  geom_edge_link() +
  geom_node_point()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions