PnodeStates {Peanut} | R Documentation |
This function returns a list associated with a Pnode
.
The function PnodeStates
returns or manipulates them.
Depending on the implementation, states may have restrictions on the
names to it is best to stick with variable naming conventions (start
with a letter, no embedded spaces or punctuation).
PnodeStates(node) PnodeStates(node) <- value
node |
A |
value |
A character vector giving the names of the new states. the names of the states. State names may be restricted by the implementing package and should probably stick to variable naming conventions. |
The states are important when building conditional probability
tables (CPTs). In particular, the state names are used to label the
columns of the CPT. Thus, state names can be used to address arrays in the
same way that dimnames
can. In particular, the
state names can be used to index the vectors returned by
PnodeStates()
, PnodeStateTitles()
,
PnodeStateTitles()
, and PnodeStateValues()
.
The function PnodeStates()
returns a character vector whose
values and names are both set to the state names. The setter version
of this function invisibly returns the
node object.
Changing the number of states once a conditional probability table is set will change the dimensions of the table, and hence will likely remove it.
Russell Almond
Pnode
,
PnodeName()
, PnodeStateTitles()
,
PnodeStateValues()
, PnodeStateDescriptions()
,
## Not run: library(PNetica)##Requires PNetica sess <- NeticaSession() startSession(sess) anet <- CreateNetwork("Annette", session=sess) ## Discrete Nodes nodel2 <- NewDiscreteNode(anet,"TwoLevelNode") stopifnot( length(PnodeStates(nodel2))==2, PnodeStates(nodel2)==c("Yes","No") ) PnodeStates(nodel2) <- c("True","False") stopifnot( PnodeStates(nodel2)==c("True","False") ) nodel3 <- NewDiscreteNode(anet,"ThreeLevelNode",c("High","Med","Low")) stopifnot( PnodeStates(nodel3)==c("High","Med","Low"), PnodeStates(nodel3)[2]=="Med" ) PnodeStates(nodel3)[2] <- "Median" stopifnot( PnodeStates(nodel3)[2]=="Median" ) PnodeStates(nodel3)["Median"] <- "Medium" stopifnot( PnodeStates(nodel3)[2]=="Medium" ) DeleteNetwork(anet) stopSession(sess) ## End(Not run)