Based on a given network structure, I created a data frame of 100 instances for six binary variables(x1 to x6). So it's a 100 x 6 data frame of 0/1 values stored in a variable 'input_params'. Created an empty graph using statements:
library(bnlearn)
bn_graph = empty.graph(names(input_params))
But when I try fitting above parameters('input_params') in the network using
bn_nw <- bn.fit(bn_graph, input_params)
I get an error saying
Error in data.type(x) :
variable x1 is not supported in bnlearn (type: integer).
What data type conversion should I do to avoid this error? Right now its 0 or 1 in the values.
dat[] <- lapply(dat, as.factor)
– Nanon