GetNthNetwork {RNetica}R Documentation

Fetch a Netica network by its position in the Netica list.

Description

Fetches networks according to an internal sequence list of networks maintained inside of Netica. If the number passed is greater than the number of currently defined networks, this function will return NULL

Usage


GetNthNetwork(n, session = getDefaultSession())

Arguments

n

A vector of integers greater than 1.

session

An object of class NeticaSession which provides the link to the Netica environment. If not supplied, then the default value is the value of the function getDefaultSession() which is usually the value of DefaultNeticaSession in the global environment.

Details

The primary use for this function is probably to loop through all open networks. As this function will return NULL when there are no more networks, that can be used to terminate the loop.

Note that the sequence numbers can change, particularly after functions that open and close networks.

This is a wrapper for the Netica function GetNthNet_bn().

Starting with RNetica 0.5, the session object is a container which contains the open networks, so this function is no longer really needed.

Value

If n is of length 1, then a single NeticaBN object or NULL will be returned.

If n is of length greater than 1, then a list of the same length as n is returned. Each element is a NeticaBN related or NULL if the number is greater than the number of open networks.

Note

The Netica shared library uses a zero-based reference (i.e., the first net is 0), but this function subtracts 1 from the argument, so it uses a one-based reference system (the first net is 1).

Author(s)

Russell Almond

References

http://norsys.com/onLineAPIManual/index.html: GetNthNet_bn()

See Also

NeticaSession, CreateNetwork(), GetNamedNetworks()

Examples

sess <- NeticaSession()
startSession(sess)

foo <- CreateNetwork("foo",sess)
bar <- CreateNetwork("bar",sess)

count <- 1
while (!is.null(net <- GetNthNetwork(count,sess))) {
  cat("Network number ",count," is ",NetworkName(net),".\n")
  count <- count +1
}
cat("Found ",count-1," networks.\n")
stopifnot(count==3L)

stopSession(sess)


[Package RNetica version 0.5-4 Index]