R/makeTfuns.R

Defines functions makeTfuns

Documented in makeTfuns

##' Make functions to evaluate tree
##' 
##' This function prepares functions that evaluate the strings generated by \code{getAQ}.
##' The default quantities for mean calculation over tree are `cost` and `qol`,
##' but others can be specified and will work as long as these
##' variables are defined at all nodes of the tree.
##'
##' @template args-node
##' @param qnt Quantity
##' @return A \code{list} of functions
##' @author Pete Dodd
##' @export
makeTfuns <- function(node,qnt=c('cost','qol')){
  ss <- lapply(qnt,function(x) getAQ(node,x))
  ss <- lapply(ss, function(x) parse(text=x))
  ans <- lapply(ss,function(x) function(dat) eval(x,envir=dat))
  names(ans) <- paste0(qnt,'fun')
  ans
}
petedodd/HEdtree documentation built on Dec. 5, 2022, 6:22 a.m.