\name{integerCodes} \alias{integerCodes} \title{ An internal function for making keys to use in the generation of a translation table in the pretest description file. } \usage{ integerCodes(values,intCode) } \arguments{ \item{values}{Vector of legal values for a variable.} \item{intCode}{Controls the recoding of variable values, according to the following table:\cr \code{intCode = NULL} --- \emph{key}=\emph{value} (identity map) \cr \code{intCode = 1} --- 1 based integer coding, lowest (last) to highest (first) (BUGS) \cr \code{intCode = 0} --- 0 based integer coding, lowest (last) to highest (first) (Parscale) \cr \code{intCode = -1} --- StatShop 0 based coding, highest(first) to lowest(last) } } \value{ A vector whose names correspond to the \code{values} argument and whose values correspond to how those values should be coded in the CSV file. } \description{ This function automatically generates the key--value pairs to use in the construction of translation tables. In particular, it allows integer coding of observables for use with programs like Parscale and BUGS. Note that StatShop stores variable state lists with the highest value first. Thus, the natural coding for a StatShop variable is to assign index 0 to "High". This is different from most other programs. } \seealso{ \code{\link{amdToPD}}, \code{\link{writeTranslationTable}} } \examples{ ## Don't recode stopifnot(identical( integerCodes(c("High","Medium","Low"),NULL), c("High"="High", "Medium"="Medium", "Low"="Low") )) \dontshow{ ## identical doesn't work in the following example } ## BUGS coding stopifnot(all.equal( integerCodes(c("High","Medium","Low"),1), c("High"=3, "Medium"=2, "Low"=1) )) ## Parscale coding stopifnot(all.equal( integerCodes(c("High","Medium","Low"),0), c("High"=2, "Medium"=1, "Low"=0) )) ## StatShop coding stopifnot(all.equal( integerCodes(c("High","Medium","Low"),-1), c("High"=0, "Medium"=1, "Low"=2) )) } \keyword{interface}