PnetWarehouse-class | R Documentation |
"PnetWarehouse"
A Warehouse
object which holds and builds
Pnet
objects. In particular, its
WarehouseManifest
contains a network manifest (see
BuildNetManifest
) which contains information about how
to either load the networks from the file system, or build them on
demand.
The PnetWarehouse
either supplies prebuilt nets or builds them
from the instructions found in the manifest. In particular, the
function WarehouseSupply
will attempt to:
Find an existing network with name
.
Try to read the network from the location given in the
Pathname
column of the manifest.
Build a blank network, using the metadata in the manifest.
The manifest is an object of type data.frame
where
the columns have the values show below. The key is the “Name”
column which should be unique for each row. The name argument to
WarehouseData
should be a character scalar corresponding to
name, and it will return a data.frame
with a single row.
A character value giving the name of the network. This
should be unique for each row and normally must conform to variable
naming conventions. Corresponds to the function PnetName
.
An optional character value giving a longer human readable name
for the netowrk. Corresponds to the function PnetTitle
.
If this model is incomplete without being joined to another
network, then the name of the hub network. Otherwise an empty
character vector. Corresponds to the function PnetHub
.
The location of the file from which the network should
be read or to which it should be written. Corresponds to the function
PnetPathname
.
An optional character value documenting the purpose
of the network. Corresponds to the function
PnetDescription
.
The function BuildNetManifest
will build a manifest for
an existing collection of networks.
A virtual Class: No objects may be created from it.
Classes can register as belonging to this abstract class. The trick
for doing this is:
setIs("NethouseClass","PnetWarehouse")
Currently BNWarehouse
is an example of an object
of this class.
signature(warehouse =
"PnetWarehouse", name = "character")
. This finds a network
with the appropriate name. If one does not exist, it is created
by reading it from the pathname specified in the manifest. If
no file exists at the pathname, a new blank network with the
properities specified in the manifest is created.
signature(warehouse =
"PnetWarehouse", name = "character")
. This fetches the network
with the given name, or returns NULL
if it has not been
built.
signature(warehouse =
"PnetWarehouse", name = "character")
. This loads the network
from a file or builds the network using the data in the Manifest.
signature(warehouse =
"PnetWarehouse", name = "character")
. This removes the network
from the warehouse inventory.
signature(warehouse =
"PnetWarehouse")
. This removes all networks
from the warehouse inventory.
signature(obj =
"PnetWarehouse")
. This returns TRUE
.
signature(warehouse =
"PnetWarehouse")
. This returns the data frame with
instructions on how to build networks. (see Details)
signature(warehouse =
"PnetWarehouse", value="data.frame")
. This sets the data
frame with instructions on how to build networks.(see Details)
signature(warehouse =
"PnetWarehouse", name="character")
. This returns the portion
of the data frame with instructions on how to build a particular
network. (see Details)
signature(warehouse =
"PnetWarehouse", serial="list")
. This restores a serialized
network, in particular, it is used for saving network state across
sessions. See PnetSerialize
for an example.
In the PNetica
implementation, the
BNWarehouse
implementatation contains an
embedded NeticaSession
object. When
WarehouseSupply
is called, it attempts to satisfy the demand by
trying in order:
Search for the named network in the active networks in the session.
If not found in the session, it will attempt to load the
network from the Pathname
field in the manifest.
If the network is not found and there is not file at the target pathename, a new blank network is built and the appropriate fields are set from the metadata.
Russell Almond
Warehouse
, WarehouseManifest
,
BuildNetManifest
Implementation in the PNetica
package:
BNWarehouse
,
MakePnet.NeticaBN
## Not run:
library(PNetica) ## Example requires PNetica
sess <- NeticaSession()
startSession(sess)
## BNWarehouse is the PNetica Net Warehouse.
## This provides an example network manifest.
netman1 <- read.csv(system.file("auxdata", "Mini-PP-Nets.csv",
package="PNetica"),
row.names=1, stringsAsFactors=FALSE)
Nethouse <- BNWarehouse(manifest=netman1,session=sess,key="Name")
CM <- WarehouseSupply(Nethouse, "miniPP_CM")
EM <- WarehouseSupply(Nethouse, "PPcompEM")
DeleteNetwork(list(CM,EM))
stopSession(sess)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.