R/getCovariatesFromTree.R

Defines functions getCovariatesFromTree

# return the names of all covariates that are used for splitting nodes in a given tree
getCovariatesFromTree <- function(tree) {
  if (tree$caption == "TERMINAL") {
    return()
  } else {
    l <- getCovariatesFromTree(tree$left_child)
    r <- getCovariatesFromTree(tree$right_child)
    return(unique(c(l, r, tree$rule$name)))
  }
}

Try the semtree package in your browser

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

semtree documentation built on Nov. 26, 2023, 5:07 p.m.