ggdag icon indicating copy to clipboard operation
ggdag copied to clipboard

Improve coordinates api

Open malcolmbarrett opened this issue 5 years ago • 3 comments

I think the coordinates API is unclear, as several people (myself included) have stumbled over it or missed it altogether. I think this needs a few changes:

  • [ ] Examples in the new customizing DAGs vignette
  • [ ] A separate function that can specify coordinates, something like dag_coords() that will override dagitty object coords and, if it's already tidied, update the tidy_dag coords.

However, I need to think about the second item more

malcolmbarrett avatar Dec 06 '19 15:12 malcolmbarrett

FWIW, I think the API is very straightforward and natural. But it would be nice to have an example with a data.frame or tribble in the documentation. Personally, I tend to specify coordinates using something like this, since it makes the X-Y coordinates clearer:

library(ggdag)

coords <- read.table(header = TRUE, text = "
  x y name
  0 0 X
  1 0 Z
  2 0 Y
  1 1 U
")

d <- dagify(
  X ~ U,
  Z ~ X,
  Y ~ Z,
  Y ~ U,
  coords = coords)

ggdag(d)

vincentarelbundock avatar Jan 24 '21 15:01 vincentarelbundock

I agree that this way is much clearer and should be more evident in the docs. I think any improvements will center around using the data frame approach

malcolmbarrett avatar Jan 24 '21 16:01 malcolmbarrett

@vincentarelbundock this is a helpful suggestion. Thank you.

go-bayes avatar Dec 01 '21 08:12 go-bayes