Learn R Programming

shinystan (version 2.1.0)

model_code: Add model code to a shinystan object or see the code currently stored in a shinystan

Description

Add model code to a shinystan object or see the code currently stored in a shinystan

Usage

model_code(sso, code)

Arguments

Value

If code is missing then any code currently stored in sso is returned as a character string. If code is specified then then any previous code is overwritten by the text in code and an updated shinystan object is returned.

Details

If code is specified it should be be a character string that can be used as an argument to cat. See Examples, below.

See Also

cat

Examples

Run this code
# Some JAGS-style code we might want to add
my_code <- "
 model {
   for (i in 1:length(Y)) {
     Y[i] ~ dpois(lambda[i])
     log(lambda[i]) <- inprod(X[i,], theta[])
   }
   for (j in 1:J) {
     theta[j] ~ dt(0.0, 1.0, 1.0)
   }
 }
"

# Add the code to a shinystan object sso
sso <- model_code(sso, my_code)

# View the code currently stored in sso
model_code(sso)

Run the code above in your browser using DataLab