suyusung / R2jags

R2jags: Using R to Run 'JAGS'
8 stars 3 forks source link

Add a `quiet` argument to jags() #10

Closed wlandau closed 3 years ago

wlandau commented 3 years ago

This PR adds a quiet argument to jags() to suppress output from rjags::jags.model(). The following code no longer writes to stdout.

  model <- "model {
    for (i in 1:n) {
      y[i] ~ dnorm(x[i] * beta, 1)
    }
    beta ~ dnorm(0, 1)
  }"
  model_file <- tempfile()
  writeLines(model, model_file)
  data <- list(
    n = 10,
    x = rnorm(10),
    y = rnorm(10)
  )
  out <- R2jags::jags(
    data,
    parameters.to.save = "beta",
    model.file = model_file,
    n.chains = 4,
    quiet = TRUE,
    progress.bar = "none"
  )