我在这里想念什么?我已经清理了工作区并重新启动了会话。这是我似乎引起麻烦的代码部分。我正在尝试从强度对象平均贝叶斯网络弧强度,然后保存该平均图的所有节点,然后计算相关节点,保存为字符串向量:
averaged = averaged.network (strength)
nodes.averaged = unique(unlist(arcs(averaged)))
relevant.nodes = nodes(averaged)[sapply(nodes.averaged, degree, object = averaged) > 0]
averagedNew = subgraph(averaged,relevant.nodes)
然后我得到这个错误:
Error in check.nodes(nodes, graph = x, max.nodes = length(x$nodes)) :
nodes must be a vector of character strings, the labels of the nodes.
这是我的相关节点:
[1] "V81" "V97" "V114" "V55" "V93" "V119" "V102" "V23" "V24" "V76" "V67" "V29" "V33" "V84" "V89" "V73"
[17] "V82" "V71" "V45" "V7" "V21" "V109" "V5" "V41" "V65" "V118" "V6" "V20" "V100" "V15" "V59" "V94"
[33] "V57" NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[49] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[65] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[81] NA NA NA NA NA NA NA NA NA NA
当我检查引发此错误消息的地方的源代码时,我找到了 if 语句 ( Link )
# nodes must be a vector of character strings.
if (!is(nodes, "character"))
stop("nodes must be a vector of character strings, the labels of the nodes.")
并运行它:
(!is(relevant.nodes, "character"))
结果是
[1] FALSE
有人有想法吗?我对 R 比较陌生,但仍然发现自己正在学习=
和<-
昨天的区别,所以请不要对我太苛刻。