MoTBFs (version 1.2)

r.data.frame: Initialize Data Frame

Description

The function r.data.frame() initializes a data frame with as many columns as nodes in the MoTBF-network. It also asings each column its data type, i.e., numeric or character. In the case of character columns, the states of the variable are extracted from the "bn" argument and included as levels.

Usage

r.data.frame(bn, dag)

Arguments

bn

A list of lists obtained from the function MoTBFs_Learning.

dag

An object of class "bn", representing the graph of the bayesian network.

Value

An object of class "data.frame", which contains the data type of each column and has no rows.

Examples

Run this code
# NOT RUN {
## Create a dataset
  # Continuous variables
  x <- rnorm(100)
  y <- rnorm(100)
  
  # Discrete variable
  z <- sample(letters[1:2],size = 100, replace = TRUE)
  
  data <- data.frame(C1 = x, C2 = y, D1 = z, stringsAsFactors = FALSE)
  
## Get DAG
  dag <- LearningHC(data)
  
## Learn a BN
  bn <- MoTBFs_Learning(dag, data, POTENTIAL_TYPE = "MTE")
  
## Initialize a data.frame containing 3 columns (x, y and z) with their attributes.
  r.data.frame(bn, dag)
# }

Run the code above in your browser using DataLab