View source: R/BUGS_readBUGS.R
| nimbleCode | R Documentation |
nimbleModel or readBUGSmodelTakes one or more R expressions or code objects, combines them if necessary, and returns the
resulting code as an R call object in the form needed by nimbleModel
and optionally usable by readBUGSmodel.
nimbleCode(...)
... |
One or more R code expressions or objects containing R code, providing the code for the model. See details. |
You may provide code to nimbleCode in two ways. The first way
is to provide the code as an argument directly, wrapped in curly brackets ({}).
The second is to create an object containing code with either nimbleCode or quote,
and pass that object to nimbleCode. You may mix and match these two approaches.
Note that code provided directly but not wrapped in {} will be rejected.
When multiple pieces of code are provided as arguments, they will be combined into
a single code object by nimbleCode and unnecessary curly brackets will be
automatically removed.
When providing a single block of code directly, the result from nimbleCode
is equivalent to using the R function quote. nimbleCode is
simply provided as a more readable alternative for NIMBLE users not familiar with quote.
Daniel Turek and Ken Kellner
# Provide a single block of code directly
code <- nimbleCode({
x ~ dnorm(mu, sd = 1)
mu ~ dnorm(0, sd = prior_sd)
})
code_new <- nimbleCode({
prior_sd ~ dhalfflat()
})
# Combine multiple previously saved code objects
code2 <- nimbleCode(code, code_new)
# Combine code and previously saved code objects
code3 <- nimbleCode({
y ~ dnorm(mu, sd = 1)
}, code, code_new)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.