cjvanlissa/tidySEM

add `edge_label` and `node_label` arguments?

mattansb opened this issue ยท 10 comments

Okay, seeing as how the graph_sem(..., label = <something>) is passed (it seems) to both get_edges() and to get_nodes(),

I think having edge_label and node_label (lazily evaluated in get_edges() and to get_nodes()) as argument in graph_sem() and in prepare_graph().

So this:

graph_sem(fit, 
          edges = get_edges(fit, label = paste(est_std, condint_std, sep = "\n"), 
          nodes = get_nodes(fit, label = "name"))

Becomes this:

graph_sem(fit, edge_label = paste(est_std, condint_std, sep = "\n"), node_label = "name")

Which is much cleaner IMO ๐Ÿ˜„

I don't see this happening, as it is opposed to the philosophy that each function should perform one clearly defined task.

The more likely development is that the label argument will disappear from graph_sem()

This would also mean graph_sem.lavaan() would fall out of favor any time anything (even the simplest) would be needed to change, right?

I mean if I'm already:

graph_sem(fit, 
          edges = get_edges(fit, label = "est_std"), 
          nodes = get_nodes(fit, label = "name"))

I might as well

graph_sem(edges = get_edges(fit, label = "est_std"), 
          nodes = get_nodes(fit, label = "name"),
          layout = get_layout(fit))

No?

I'd say that the most common thing people want to "control" are the labels - I think then that it merits considering this, for ease of use...

It's worth considering, but this kind of change to the user interface is not easy to revert; undoing it would mean supporting the legacy interface during a phase-out period, adding notifications that the interface is changing, etc. I'm very reluctant for that reason.

That's also why the label argument is currently still supported, even though I'd rather not have it - it would break backward compatibility

I will ditch the label argument in my teaching this year (starting this week!) hope I can convince you by next year (:

Thanks Casper for all your work!! ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐Ÿฅ‡๐Ÿฅ‡

No problem mate, debugging is a huge task so I should thank you! Remember my offer to get on board as a package author, we could discuss these interface changes on equal footing. I'm leaving this issue as an enhancement request.

BTW, instead of the syntax you wrote in the initial post, I would suggest the following makes more sense:

prepare_graph(fit) %>%
  edit_graph({label = paste(est_std, confint_std)}) %>%
  edit_graph({label = name}, "nodes") %>%
  plot()

I've documented this in the plotting graphs vignette to make it more clear.

Thanks!

I think #26 can also help resolve a similar "need" - to streamline the plotting (in one pipe?).