Package bnlearn provides functions for constraint-based structure learning and other algorithms to produce directed acyclic graph (DAG) of data. In following examples, the mtcars dataset that has information about features of different cars is used:

library(bnlearn)

res = gs(mydf) # Grow-Shrink algorithm

plot(res, main="Simple Learning Bayesian Algorithm")

Other algorithms available include Incremental Association (IAMB), the Fast Incremental Association (Fast IAMB) and the Interleaved Incremental Association (Inter IAMB) constraint-based algorithms.

Structure network using hill-climbing and Tabu greedy search algorithms are also possible:

**Code:**

> library(bnlearn)

> res = hc(mtcars)

> plot(res)

This algorithm shows more relationships.