rich-iannone / DiagrammeR

Graph and network visualization using tabular data in R

Home Page:https://rich-iannone.github.io/DiagrammeR/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove required argument ```n``` from create_node_dfs

julianbarg opened this issue · comments

Both create_node_df and add_node_df at the moment offer really little value to the user. Stripped to the core, a node df can be a character vector, with everything else being optional. One could just use a wrapper function to feed a character vector into create_node_df and if would work 100% of the time. The greatest offender is the required n argument for create_node_df which is nothing but an unnecessary math exercise. n is a function of the type or label argument. The way that the arguments are parsed also conceals the fact that the whole thing is nothing but a wrapper around a df with an id, type, and label column.

add_node_df should reflect the reality that users are capable of keeping track of types and labels themselves. Just allow the user to feed in a dataframe and require as a minimum no more than what is absolutely necessary to create a diagram--one column, either type or label with ID and everything else being optional. In fact, we don't need to even do any data validation here. As long as a meaningful error message is thrown, the average R user should really be able to figure out what is wrong.