R/bn2dagitty.R

Defines functions bn2dagitty

Documented in bn2dagitty

#' Converts a bn_df object to a dagitty object
#'
#' @param bn_df initialised bn_df object, with simulation instructions. Created with `bn_create`
#'
#' @return dagitty object
#' @export
#'
#' @examples
#'
bn2dagitty <- function(bn_df){
  dagitty_str = purrr::map2_chr(bn_df$variable, bn_df$parents, ~paste0(.x, " <- ", "{", paste0(.y, collapse=" ") , "}"))
  dagitty::dagitty(paste0("dag {", paste0(dagitty_str, collapse=" "), "}"))
}
wjchulme/dd4d documentation built on Dec. 22, 2024, 3:37 a.m.