What am I missing here? I already cleaned the workspace and restartet the session. Here is my the part of the code that seems to cause trouble. I am trying to average an bayesian networks arc strenghts from a strength object, then save all nodes of that averaged graph and then calculate the relevant nodes, saved as vector of character strings:
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)
And then I get this Error:
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.
This is my relevant.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
When I checked the source code for the place, where this error message is thrown, I found the if-statement (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.")
and ran it:
(!is(relevant.nodes, "character"))
and the result is
[1] FALSE
Does anybody has an idea? I am rather new to R and still found myself to learn the difference between =
and <-
just yesterday, so please don't be too harsh on me.