is.legal.name {Peanut} | R Documentation |
Objects in a warehouse may have restrictions on the names that are
allowed. For example, Netica nodes and nets must have names that
follow common variable naming convention (alphanumeric, starts with a
letter, no embedded spaces, etc.). The function is.legal.name
checks the name type, and as.legal.name
munges the name so that
it is legal.
is.legal.name(warehouse, name) as.legal.name(warehouse, name)
warehouse |
A warehouse which defines the type of object. |
name |
A character vector giving names to be tested or munged. |
For is.valid.name
, a logical value returning the result of each
test.
For as.valid.name
, a character vector with the modified names.
The BNWarehouse
and
NNWarehouse
have a prefix
field which is
used to ensure that names always start with a letter.
Russell Almond
## Not run: ## Requires PNetica library(PNetica) sess <- NeticaSession() startSession(sess) ## BNWarehouse is the PNetica Net Warehouse. ## This provides an example network manifest. table.dir <- file.path(library(help="Peanut")$path, "auxdata") net.dir <- file.path(library(help="PNetica")$path, "testnets") netman1 <- read.csv(file.path(table.dir,"Mini-PP-Nets.csv"), row.names=1, stringsAsFactors=FALSE) Nethouse <- BNWarehouse(manifest=netman1,session=sess,key="Name", address=net.dir,prefix="S") stopifnot(is.legal.name(Nethouse,c("CamelCase","Embedded Space")) == c(TRUE,FALSE), as.legal.name(Nethouse,"100c3") == "S100c3") ## This expression provides an example Node manifest nodeman1 <- read.csv(file.path(table.dir,"Mini-PP-Nodes.csv"), row.names=1,stringsAsFactors=FALSE) Nodehouse <- NNWarehouse(manifest=nodeman1, key=c("Model","NodeName"), session=sess,prefix="V") stopifnot(is.legal.name(Nodehouse,c("Neg1","-1")) == c(TRUE,FALSE), as.legal.name(Nodehouse,1) == "V1") ## End(Not run)