We have an issue here that dag does not contain the information we need
for plot_model
I wonder should we remove or rename model$dag.
We only use it for accessing the list of parents. So we could just have a list
of parents as an attribute on model$parents_df
Here’s a function to generate the list and replace get_parents:
generate_node_parents_list <- function(df) {
# Initialize an empty list
node_parents_list <- list()
# Iterate over each row of the data frame
for (i in 1:nrow(df)) {
node <- df$node[i]
parent_nodes <- df$parent_nodes[i]
# Split the parent nodes by comma and remove any whitespace
parent_nodes_list <- unlist(strsplit(parent_nodes, ",\\s*"))
# Assign the parent nodes to the corresponding node in the list
node_parents_list[[node]] <- parent_nodes_list
}
node_parents_list[df$parent_nodes != ""]
}
Need to be sure it goes in the right order and does not break anything
@macartan --> revised function etc. is in the linked branch. Let me know if we should kill dag entirely or if you want to make dag a plotable object (e.g. rename statement to dag)
We have an issue here that
dag
does not contain the information we need forplot_model
I wonder should we remove or renamemodel$dag
. We only use it for accessing the list of parents. So we could just have a list of parents as an attribute onmodel$parents_df
Here’s a function to generate the list and replace get_parents:
Need to be sure it goes in the right order and does not break anything