Description Usage Arguments References Examples
Interactive Bayesian Network Viewer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  | viewer(
  bayesianNetwork,
  bayesianNetwork.background = NULL,
  bayesianNetwork.title = "",
  bayesianNetwork.subtitle = "",
  bayesianNetwork.footer = "",
  bayesianNetwork.enabled.interactive.mode = FALSE,
  bayesianNetwork.layout = "default",
  bayesianNetwork.width = "100%",
  bayesianNetwork.height = "500px",
  bayesianNetwork.data = NULL,
  bayesianNetwork.correlation.show = FALSE,
  bayesianNetwork.correlation.method = "pearson",
  node.shape = NULL,
  node.label.prefix = "",
  node.colors = list(),
  node.font = list(),
  edges.smooth = TRUE,
  edges.dashes = FALSE,
  edges.width = 1,
  edges.font.size = 18,
  edges.font.color = "black",
  edges.shadow = FALSE,
  options.highlightNearest = TRUE,
  options.nodesIdSelection = FALSE,
  clusters.legend.title = "",
  clusters.legend.options = list(),
  clusters = list()
)
 | 
bayesianNetwork | 
 A Bayesian Network structure. (Example : hill-climbing (HC)).  | 
bayesianNetwork.background | 
 Bayesian network background  | 
bayesianNetwork.title | 
 : String. Bayesian Network title  | 
bayesianNetwork.subtitle | 
 : String. Bayesian Network subtitle  | 
bayesianNetwork.footer | 
 : String. Bayesian Network footer  | 
bayesianNetwork.enabled.interactive.mode | 
 : Boolean. Enabled interactive viewer mode.  | 
bayesianNetwork.layout | 
 : String. A layout of a Bayesian Network. The hierarchical layout the available options are: UD, DU, LR, RL. To simplify: up-down, down-up, left-right, right-left. 
  | 
bayesianNetwork.width | 
 : String. Bayesian Network width  | 
bayesianNetwork.height | 
 : String. Bayesian Network height  | 
bayesianNetwork.data | 
 : List. Data Set.  | 
bayesianNetwork.correlation.show | 
 : Boolean. When true, show Correlation Coefficient. Default (FALSE).  | 
bayesianNetwork.correlation.method | 
 : String. Correlation Coefficient. One of "pearson" (default), "kendall", or "spearman"  | 
node.shape | 
 : String. A node shape of a Bayesian Network 
  | 
node.label.prefix | 
 : String. Adds a prefix to the node label  | 
node.colors | 
 : String | named list. Color for the node. Can be 'rgba(120,32,14,1)', '#97C2FC' (hexa notation on 7 char without transparency) or 'red'. Can be just one color, or a list with several elements: 
  | 
node.font | 
 : Array. Example list(color = "black", face="Arial")  | 
edges.smooth | 
 : Boolean. When true, the edge is drawn as a dynamic quadratic bezier curve.  | 
edges.dashes | 
 : Array or Boolean. Default to false. When true, the edge will be drawn as a dashed line.  | 
edges.width | 
 : Number. Sets edge width. Default to 1.  | 
edges.font.size | 
 : Number. Font Size. Default to 18.  | 
edges.font.color | 
 : String. Font Color. Default to 'black'.  | 
edges.shadow | 
 : Boolean. Shadow. Default to FALSE.  | 
options.highlightNearest | 
 : Boolean. Default to true. Highlight nearest when clicking a node.  | 
options.nodesIdSelection | 
 : Boolean. Default to false. Add an id node selection creating an HTML select element.  | 
clusters.legend.title | 
 : Array. Get details in the example.  | 
clusters.legend.options | 
 : Array of Array. Get details in the example.  | 
clusters | 
 : Array of Array. Get details in the example.  | 
See online documentation http://robsonfernandes.net/bnviewer
See the code fontAwesome for icons in groups and nodes https://fontawesome.com/v4.7.0/cheatsheet/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70  | library(bnlearn)
library(bnviewer)
data("alarm")
bayesianNetwork = hc(alarm)
viewer(bayesianNetwork,
       bayesianNetwork.background = "-webkit-radial-gradient(center, ellipse cover,
                                                             rgba(255,255,255,1) 0%,
                                                             rgba(246,246,246,1) 47%,
                                                             rgba(237,237,237,1) 100%)",
       bayesianNetwork.width = "100%",
       bayesianNetwork.height = "100vh",
       bayesianNetwork.layout = "layout_components",
       bayesianNetwork.title="<br>Discrete Bayesian Network - Alarm",
       bayesianNetwork.subtitle = "Monitoring of emergency care patients",
       node.colors = list(background = "white",
                          border = "black",
                          highlight = list(background = "#e91eba",
                                           border = "black")),
       node.font = list(color = "black", face="Arial"),
       clusters.legend.title = list(text = "<b>Legend</b> <br> Variable Categories",
                                    style = "font-size:18px;
                                             font-family:Arial;
                                             color:black;
                                             text-align:center;"),
       clusters.legend.options = list(
         list(label = "Pressure",
              shape = "icon",
              icon = list(code = "f1ce",
                          size = 50,
                          color = "#e91e63")),
         list(label = "Volume",
              shape = "icon",
              icon = list(code = "f140",
                          size = 50,
                          color = "#03a9f4")),
         list(label = "Ventilation",
              shape = "icon",
              icon = list(code = "f192",
                          size = 50,
                          color = "#4caf50")),
         list(label = "Saturation",
              shape = "icon",
              icon = list(code = "f10c",
                          size = 50,
                          color = "#ffc107"))
       ),
       clusters = list(
         list(label = "Pressure",
              shape = "icon",
              icon = list(code = "f1ce", color = "#e91e63"),
              nodes = list("CVP","BP","HRBP","PAP","PRSS")),
         list(label = "Volume",
              shape = "icon",
              icon = list(code = "f140", color = "#03a9f4"),
              nodes = list("MINV","MVS","LVV","STKV")),
         list(label = "Ventilation",
              shape = "icon",
              icon = list(code = "f192", color = "#4caf50"),
              nodes = list("VALV","VLNG","VTUB","VMCH")),
         list(label = "Saturation",
              shape = "icon",
              icon = list(code = "f10c", color = "#ffc107"),
              nodes = list("HRSA","SAO2","PVS"))
       )
)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.