R/decode.parameter.name.R

"decode.parameter.name" <-
function (a){
#
# Decodes Bugs parameter names
#   (e.g., "beta[3,14]" becomes "beta" with 2 indexes:  3 and 14)
# for use by the bugs.sim() function
#
  left.bracket <- regexpr ("[[]", a)
  if (left.bracket==-1){
    root <- a
    dimension <- 0
    indexes <- NA
  }
  else {
    root <- substring (a, 1, left.bracket-1)
    right.bracket <- regexpr ("[]]", a)
    a <- substring (a, left.bracket+1, right.bracket-1)
    indexes <- as.numeric(unlist(strsplit(a, ",")))
    dimension <- length(indexes)
  }
  list(root=root, dimension=dimension, indexes=indexes)
}

Try the R2WinBUGS package in your browser

Any scripts or data that you put into this service are public.

R2WinBUGS documentation built on June 24, 2024, 5:18 p.m.