PnetSerialize | R Documentation |
Methods for functions PnetSerialize
and
unserializePnet
in package Peanut, which serialize
NeticaBN
objects. Note that in this case, the
factory is the NeticaSession
object. These
methods assume that there is a global variable with the name of the
session object which points to the Netica session.
PnetSerialize
, signature(net = "NeticaBN")
Returns a vector with three components. The name
field is the
name of the network. The data
component is a raw vector
produced by calling serialize(...,NULL)
on the
output of a WriteNetworks
operation. The
factory
component is the name of the
NeticaSession
object. Note that the
PnetUnserialize
function assumes that there is a
global variable with name given by the factory argument which contains
an appropriate NeticaSession
object for the restoration.
unserializePnet
, signature(factory = "NeticaSession")
This method reverses the previous one. In particular, it applies
ReadNetworks
to the serialized object.
## Need to create session whose name is is the same a the symbol it is
## stored in.
MySession <- NeticaSession(SessionName="MySession")
startSession(MySession)
irt5 <- ReadNetworks(system.file("sampleNets","IRT5.dne",
package="RNetica"), session=MySession)
NetworkAllNodes(irt5)
CompileNetwork(irt5) ## Ready to enter findings
NodeFinding(irt5$nodes$Item_1) <- "Right"
NodeFinding(irt5$nodes$Item_2) <- "Wrong"
## Serialize the network
irt5.ser <- PnetSerialize(irt5)
stopifnot (irt5.ser$name=="IRT5",irt5.ser$factory=="MySession")
NodeFinding(irt5$nodes$Item_3) <- "Right"
## now revert by unserializing.
irt5 <- PnetUnserialize(irt5.ser)
NetworkAllNodes(irt5)
stopifnot(NodeFinding(irt5$nodes$Item_1)=="Right",
NodeFinding(irt5$nodes$Item_2)=="Wrong",
NodeFinding(irt5$nodes$Item_3)=="@NO FINDING")
DeleteNetwork(irt5)
stopSession(MySession)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.