NetworkName {RNetica} | R Documentation |
Gets or sets the name of the network. Names must conform to the
IDname
rules.
NetworkName(net, internal=FALSE) NetworkName(net) <- value
net |
A |
internal |
A logical scalar. If true, the actual Netica object will be consulted, if false, a cached value in the R object will be used. |
value |
A character scalar containing the new name. |
Network names must conform to the IDname
rules for
Netica identifiers. Trying to set the network to a name that does not
conform to the rules will produce an error, as will trying to set the
network name to a name that corresponds to another different network.
The NetworkTitle()
function provides another way to name
a network which is not subject to the IDname
restrictions.
Note that the name of the network is stored in two places: in the
Name
field of the NeticaBN
object
(net$Name
), and internally in the Netica object. These
should be the same; however, may not be. The internal
field is
used to force a check of the internal Netica object rather than the
field in the R object.
The name of the network as a character vector of length 1.
The setter method returns the modified object.
This paragraph is obsolete as of RNetica version 0.5, it describes the previous versions only.
NeticaBN
objects are internally implemented as character vectors
giving the name of the network. If a network is renamed, then it is
possible that R will hold onto an old reference that still using the
old name. In this case, NetworkName(net)
will give the correct
name, and GetNamedNets(NetworkName(net))
will return a
reference to a corrected object.
Starting with RNetica 0.5, NeticaBN
objects are
cached in the NeticaSession
object. The setter
method for NetworkName
updates the cache as well.
In versions of RNetica less than 0.5, trying to set the name of a node to a name that was already used would generate a warning instead of an error. It now generates an error.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: GetNetName_bn(), SetNetName_bn()
CreateNetwork()
, NeticaBN
,
GetNamedNetworks()
, NetworkTitle()
sess <- NeticaSession() startSession(sess) net <- CreateNetwork("funNet", session=sess) netcached <- net stopifnot(!is.null(sess$findNet("funNet"))) stopifnot(NetworkName(net)=="funNet") stopifnot(NetworkName(net,internal=TRUE)=="funNet") NetworkName(net)<-"SomethingElse" stopifnot(net$Name=="SomethingElse") stopifnot(is.null(sess$findNet("funNet"))) stopifnot(!is.null(sess$findNet("SomethingElse"))) stopifnot(NetworkName(net)==NetworkName(netcached)) stopifnot(NetworkName(net)==NetworkName(netcached,internal=TRUE)) net1 <- CreateNetwork("funnyNet", session=sess) cat("Next statement should generate an error message.\n") nn <- try(NetworkName(net1) <- "SomethingElse") stopifnot(is(nn,"try-error")) DeleteNetwork(net) DeleteNetwork(net1) stopSession(sess)