##' A plotter for decision tree models
##'
##' This is a simplified plotting utility that allows visual checking of decision
##' tree models. By default, the node names, costs, HRQoLs are displayed as well
##' as the edge probabilities. The node attributes to display can be specified in
##' `varz`. The boolean `edgelabel` variable allows turning the edge labels off.
##'
##' @template args-node
##' @param varz Variables
##' @param edgelabel Edge labels
##' @return \code{DiagrammeR} object
##' @author Pete Dodd
##' @importFrom grDevices dev.off pdf png
##' @importFrom graphics curve title
##' @importFrom stats dbeta dexp dgamma dlnorm dnorm
##' qbeta qexp qgamma qlnorm qnorm rbeta
##' rexp rgamma rlnorm rmultinom rnorm runif
##' @importFrom utils write.csv
##' @import ggplot2
##' @md
##' @export
plotter <- function(node, varz=c('name','cost','qol'), edgelabel = TRUE) {
nodelab <- function(x) GetNodeLabel(x, varz=varz)
if (edgelabel) {
data.tree::SetEdgeStyle(node, fontname = 'helvetica', label = GetEdgeLabel)
} else {
data.tree::SetEdgeStyle(node, fontname = 'helvetica', label = '')
}
data.tree::SetNodeStyle(node, fontname = 'helvetica', label = nodelab, shape = 'box')
data.tree::SetGraphStyle(node, rankdir = "LR")
plot(node)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.