foreign: Read and write BIF, NET, DSC and DOT files

foreign files utilitiesR Documentation

Read and write BIF, NET, DSC and DOT files


Read networks saved from other programs into objects, and dump bn and objects into files for other programs to read.


# Old (non-XML) Bayesian Interchange format.
read.bif(file, debug = FALSE)
write.bif(file, fitted)

# Microsoft Interchange format.
read.dsc(file, debug = FALSE)
write.dsc(file, fitted)

# HUGIN flat network format., debug = FALSE), fitted)

# Graphviz DOT format., graph)



a connection object or a character string.


an object of class


an object of class bn or


a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.


read.bif(), read.dsc() and return an object of class

write.bif(), write.dsc(), and return NULL invisibly.


All the networks present in the Bayesian Network Repository have associated BIF, DSC and NET files that can be imported with read.bif(), read.dsc() and

HUGIN can import and export NET files; Netica can read (but not write) DSC files; and GeNIe can read and write both DSC and NET files.

DOT files can be read by Graphviz, Gephi and a variety of other programs.

Please note that these functions work on a "best effort" basis, as the parsing of these formats have been implemented by reverse engineering the file format from publicly available examples.


Marco Scutari


Bayesian Network Repository,

bnlearn documentation built on May 29, 2024, 5:07 a.m.