How to do it...

In this recipe, we will work with a dataset containing several features for the employees of a certain company: the area, the sleep quality, whether they recently had a child, diet quality, travel time and performance. In this example, all these features have two levels, but that is obviously not a requirement:

  1. First, we load the dataset, we define the network, and we plot it. We could use several networks, but this one is a reasonable one to begin with. Note that the performance (maybe the most relevant variable for us here) is impacted by two variables:diet_quality and travel_time. Presumably, people that must travel more are more tired and perform worse at work; also, people who are not eating well, may feel too tired ...

Get R Statistics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.