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
#' @export
#' @return A \code{list} of parents in a DAG
#' @examples
#' model <- make_model('X -> K -> Y')
#' get_parents(model)

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

Try the CausalQueries package in your browser

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

CausalQueries documentation built on Oct. 20, 2023, 1:06 a.m.