makeBUGSFriendlyNames: Ensure That a Variable Name is BUGS-Compliant

View source: R/mcmcInternals.R

makeBUGSFriendlyNamesR Documentation

Ensure That a Variable Name is BUGS-Compliant

Description

R is quite permissive with variables names and not all variable names allowed by R will result in functioning BUGS code. NIMBLE uses a dialect of BUGS and so this function will automatically convert variables names such that they can be interpreted correctly

Usage

makeBUGSFriendlyNames(inNames, warnType = NA, allowLeadingUnderscore = FALSE)

Arguments

inNames

A character vector of variable names to ensure are BUGS-compliant

warnType

A character scalar denoting whether to produce feedback to the user if the variable names provided in inNames are non-compliant. "message", "warning", or "error" gives a message, warning, or error respectively. All other values for warnType result in no feedback being given to the user

allowLeadingUnderscore

A logical scalar denoting whether leading undercores are allowed in the name. This is usually not acceptable naming convention (hence the default to FALSE) but can be useful when processing suffix names

Value

A character vector of BUGS-compliant variable names

Author(s)

Joseph D. Chipperfield, joechip90@googlemail.com

See Also

nimbleCode

Examples

# A mixture of variable names
inputNames <- c(
  "aGoodVariableName1", "aGoodVariableName2", # Compliant names
  "1aBadVariableName", "aBadVariableName{2}"  # Non-compliant names
)
outputNames <- makeBUGSFriendlyNames(inputNames, "message")
# outputNames now contains compliant conversions of the non-compliant names


joechip90/PaGAn documentation built on April 17, 2025, 4:05 p.m.