network
network copied to clipboard
`[<-.network` error with missing edge
The following example shows how %e%<-
and [<-.network
(with names.eval
passed) behave similarly with no missing edges, but the latter errors when an edge is missing.
require(network)
nw <- network.initialize(3, directed = FALSE)
nw[1,2] <- 1
nw[2,3] <- 1
nw %e% "attr1" <- "b"
nw %e% "attr1"
nw[,,names.eval="attr2"] <- "c"
nw %e% "attr2"
nw[2,3] <- NA
nw %e% "attr3" <- "d"
nw %e% "attr3"
nw[,,names.eval="attr4"] <- "e"
the error on the last line being
Error in if (is.adjacent(x, el[k, 1], el[k, 2], na.omit = FALSE)) { :
missing value where TRUE/FALSE needed
with traceback
> traceback()
2: `[<-.network`(`*tmp*`, , , names.eval = "attr4", value = "e")
1: `[<-`(`*tmp*`, , , names.eval = "attr4", value = "e")
This is easily fixed, but it's a "philosophical" question: if an edge is marked as missing (i.e., has its na
attribute set to TRUE
), what value should this call assign to it?
In the above case, what should the attribute attr4
of edge (2,3) be assigned?
- Nothing.
-
"e"
. -
NA
(NA
of typelogical
). -
NA_character_
(NA
of the same type as the assigned value).
@CarterButts, what do you think?