PnodeStateTitles: Accessors for the titles and descriptions associated with...

PnodeStateTitlesR Documentation

Accessors for the titles and descriptions associated with states of a parameterized node.

Description

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.

Usage

PnodeStateTitles(node)
PnodeStateTitles(node) <- value
PnodeStateDescriptions(node)
PnodeStateDescriptions(node) <- value

Arguments

node

A Pnode object whose state titles or descriptions will be accessed.

value

A character vector of the same length as the number of states length(PnodeStates(node)) which provides the new state titles or descriptions.

Details

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.

Value

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.

Author(s)

Russell Almond

See Also

Pnode, PnodeStates(), PnodeStateValues()

Examples

## 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)

ralmond/Peanut documentation built on Sept. 19, 2023, 8:27 a.m.