我在R中遇到一个问题,使用bnlearn包
以下是我的测试数据(完整数据集为20000行):
数据
>test_bis
Ohno.Duplicates disease.Y complex.Y
0 0 0
0 0 0
0 1 0
0 0 0
0 0 0问题
> test=hc(test_bis, score="bde")
Error in check.score(score, x) :
core 'bde' may be used with discrete data only.我不明白为什么我的数据不是离散的,因为只有0和1。这会是一个类型问题吗
或者更一般地说:函数如何决定什么是“离散的”?
发布于 2016-07-10 18:54:35
将数字列转换为因子解决了这个问题。下面的代码将转换为要因子的数值列。
cols <- sapply(dat, is.numeric) dat[,cols] <- lapply(dat[,cols], as.factor)
https://stackoverflow.com/questions/34614194
复制相似问题