children_of_parents: Get child locations given parent IDs from IHME hierarchies

View source: R/children_of_parents.R

children_of_parentsR Documentation

Get child locations given parent IDs from IHME hierarchies

Description

children_of_parents() finds children from IHME Hierarchies, given a vector of location_ids.v From a hierarchy, which children are have a given parent ID in the path_to_top_parent column? Returns logical T/F vector.

Usage

children_of_parents(
  parent_loc_ids,
  hierarchy,
  output = "loc_ids",
  include_parent = FALSE
)

Arguments

parent_loc_ids

[numeric] vector of parent location_ids

hierarchy

[data.table] Which hierarchy to use? (Uses 'path_to_top_parent' to find all nested children)

output

[character] Output options:

  • "boolean" : mask for all rows in the hierarchy - useful for adding a new column

  • "loc_ids" : vector of child location_ids (and parent, if desired)

include_parent

[logical] Do you want parent location_id included with children? (FALSE by default). If FALSE, and using two parent IDs, be careful if the parent location_ids are nested inside each other.

Value

[logical/numeric] T/F mask for all hierarchy locs, or a vector of children location_ids?

Examples


source(file.path("/ihme/cc_resources/libraries/current/r/get_location_metadata.R"))
hierarchy <- get_location_metadata(location_set_id = 111, location_set_version_id = 1050, release_id = 9)

hierarchy$children_of_china <- children_of_parents(6, hierarchy)
hierarchy$china_and_children <- children_of_parents(6, hierarchy, include_parent = TRUE)

child_locs_of_china <- children_of_parents(6, hierarchy, output = "loc_ids")


epi-sam/SamsElves documentation built on June 12, 2025, 7 a.m.