try_with_time_limit <- function(expr, cpu = Inf, elapsed = Inf) {
y <- try({setTimeLimit(cpu, elapsed); expr}, silent = TRUE)
if(inherits(y, "try-error")) NULL else y
}
render_bn <- function(bn) {
nodes <- DiagrammeR::create_nodes(nodes = names(bn))
from <- lapply(bn, function(x) x$parents)
to <- lapply(names(bn), function(x) rep(x, each = length(from[[x]])))
edges <- DiagrammeR::create_edges(from = unlist(from), to = unlist(to))
gr <- DiagrammeR::create_graph(nodes_df = nodes, edges_df = edges)
DiagrammeR::grViz(gr$dot_code)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.