Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Column Names when Calling ggraph() #208

Closed
billdenney opened this issue Sep 11, 2019 · 4 comments
Closed

Duplicate Column Names when Calling ggraph() #208

billdenney opened this issue Sep 11, 2019 · 4 comments

Comments

@billdenney
Copy link
Contributor

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()
@thommohr
Copy link

Dear Developers,

today I tried the example with the newst ggraph version. It still persists.

@thomasp85
Copy link
Owner

if you are using a precalculated layout this should just be passed directly as the graph argument:

this works:

ggraph(
  graph=model_layout
) +
  geom_edge_link() +
  geom_node_point()

I agree the error is non-sensical and I'll try to fix that part

@billdenney
Copy link
Contributor Author

Is it possible to simplify the fact that the layout should be passed as the graph argument? The two things that occur to me are:

  • Give a warning and switch the precalculated layout to the graph argument (seems easier for the user)
  • Give an error indicating that the user should make the switch of the layout argument to the graph argument.

@thomasp85
Copy link
Owner

There will be a warning

selcenari added a commit to selcenari/ceRNAnetsim that referenced this issue Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants