Skip to content

Reverse edge direction in as_tidy_dagitty() output #177

@gomesleduardo

Description

@gomesleduardo

Hi, guys!

Description

I encountered an issue with the as_tidy_dagitty() function while following the example in the documentation. The resulting
DAG object appears to store the relationships correctly, but the data tibble has the edges defined in the opposite direction.

Reproducible Example

library(ggdag)
dag <- data.frame(name = c("c", "c", "x"), to = c("x", "y", "y")) %>% 
  as_tidy_dagitty()

print(dag$data)
print(dag$dag)

Observed Behavior

Output of dag$data:

# A tibble: 4 × 8
  name       x       y direction to      xend    yend circular
  <chr>  <dbl>   <dbl> <fct>     <chr>  <dbl>   <dbl> <lgl>   
1 c     -0.572  0.911  ->        x      0.420  0.765  FALSE   
2 c     -0.572  0.911  ->        y     -0.203 -0.0206 FALSE   
3 x      0.420  0.765  ->        y     -0.203 -0.0206 FALSE   
4 y     -0.203 -0.0206 NA        NA    NA     NA      FALSE   

Output of dag$dag:

dag {
c [pos="-0.572,0.911"]
x [pos="0.420,0.765"]
y [pos="-0.203,-0.021"]
x -> c
y -> c
y -> x
}

# ARCS ARE REVERSED!

Environment

# R Version: 4.3.1
# ggdag Version: 0.2.13
# dagitty Version: 0.3-4

Would appreciate any guidance or fixes for this issue.

Thanks for your work on this package!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions