is.legal.name: Checks to see if names are valid for objects in warehouse.

is.legal.nameR Documentation

Checks to see if names are valid for objects in warehouse.

Description

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.

Usage

is.legal.name(warehouse, name)
as.legal.name(warehouse, name)

Arguments

warehouse

A warehouse which defines the type of object.

name

A character vector giving names to be tested or munged.

Value

For is.valid.name, a logical value returning the result of each test.

For as.valid.name, a character vector with the modified names.

Note

The BNWarehouse and NNWarehouse have a prefix field which is used to ensure that names always start with a letter.

Author(s)

Russell Almond

Examples

## Not run: 
## Requires PNetica
library(PNetica)

sess <- NeticaSession()
startSession(sess)

## BNWarehouse is the PNetica Net Warehouse.
## This provides an example network manifest.
table.dir <- system.file("auxdata", package="Peanut")
net.dir <- system.file("testnets", package="PNetica")

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)

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