Plot of a Bayesian network | R Documentation |
Plot of a Bayesian network.
bnplot(dag, shape = "ellipse", main = NULL, sub = NULL, highlight = NULL)
dag |
A BN object, an object of class "bn". |
shape |
A character string defining the shape of the nodes, "ellipse" (default value), "circle" or "rectangle". |
main |
The main title of the graph displayed on the top. |
sub |
The subtitle of the graph displayed at the bottom. |
highlight |
A list with options specifying which nodes to plot with different colours. You can also check the package bnlearn or the package Rgraphviz for more information on this, or simply check the example below. |
The function is called from the "bnlearn" package which invokes the "Rgraphviz" package from Bioconductor and you need to install it first.
The Bayesian network is visualised.
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
pchc, mmhc, fedhc
if (require("Rgraphviz") ) {
# simulate a dataset with continuous data
x <- matrix( rnorm(100 * 15, 1, 5), nrow = 100 )
colnames(x) <- paste("X", 1:15, sep = "")
nam <- colnames(x)
a <- pchc(x)
bnplot(a$dag)
bnplot( a$dag, highlight = list(nodes = nam[c(2, 3)],
col = "tomato", fill = "orange") )
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.