R/get_parents.R

Defines functions get_parents

Documented in get_parents

#' Get list of parents of all nodes in a model
#'
#' @inheritParams CausalQueries_internal_inherit_params
#' @return A \code{list} of parents in a DAG

get_parents <- function(model) {
  parents <- lapply(model$nodes, function(j) {
    paste(model$dag$parent)[paste(model$dag$children) == j]
  })
  names(parents) <- model$nodes
  return(parents)
}

Try the CausalQueries package in your browser

Any scripts or data that you put into this service are public.

CausalQueries documentation built on June 22, 2024, 6:50 p.m.