PnodeStateTitles | R Documentation |
Each state of a Pnode
has a short name (which could be
restricted by the implementation) and a longer title (which generally
can contain emedded spaces and other details to make it more
readable). Each state also can have a description associated with it.
These functions get or set the state titles or descriptions.
PnodeStateTitles(node)
PnodeStateTitles(node) <- value
PnodeStateDescriptions(node)
PnodeStateDescriptions(node) <- value
node |
A |
value |
A character vector of the same length as the number of states
|
The titles are meant to be a more human readable version of the state names and are not subject the variable naming restrictions. The descriptions are meant to be a longer free form notes.
Both titles and descriptions are returned as a named character vector with names corresponding to the state names. Therefore one can change a single state title or description by accessing it either using the state number or the state name.
Both PnodeStateTitles()
and PnodeStateDescriptions()
return a
character vector of length
length(PnodeStates(node))
giving the
titles or descriptions respectively. The names of this vector are
PnodeStates(node)
.
The setter methods return the modified Pnode
object invisibly.
Russell Almond
Pnode
, PnodeStates()
,
PnodeStateValues()
## Not run:
library(PNetica)##Requires PNetica
sess <- NeticaSession()
startSession(sess)
cnet <- CreateNetwork("CreativeNet", session=sess)
orig <- NewDiscreteNode(cnet,"Originality", c("H","M","L"))
PnodeStateTitles(orig) <- c("High","Medium","Low")
PnodeStateDescriptions(orig)[1] <- "Produces solutions unlike those typically seen."
stopifnot(
PnodeStateTitles(orig) == c("High","Medium","Low"),
grep("solutions unlike", PnodeStateDescriptions(orig))==1,
PnodeStateDescriptions(orig)[3]==""
)
sol <- NewDiscreteNode(cnet,"Solution",
c("Typical","Unusual","VeryUnusual"))
stopifnot(
all(PnodeStateTitles(sol) == ""),
all(PnodeStateDescriptions(sol) == "")
)
PnodeStateTitles(sol)["VeryUnusual"] <- "Very Unusual"
PnodeStateDescriptions(sol) <- paste("Distance from typical solution",
c("<1", "1--2", ">2"))
stopifnot(
PnodeStateTitles(sol)[3]=="Very Unusual",
PnodeStateDescriptions(sol)[1] == "Distance from typical solution <1"
)
DeleteNetwork(cnet)
stopSession(sess)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.