# load rjags (R interface to JAGS) 
library(rjags)

model = "tmp_model.bug"    # name of the model file ('temporary')

# write the model into del model file:
write("
model{
  x1 ~ dpois(5);          # x1 is Poisson with lambda=5
  x2 ~ dnorm(3, 1/2^2);   # x2 is Normal with mu=3 and sigma=2
                          # note how JAGS ises tau=1/sigma^2 ! 
  x3 ~ dbin(0.5, 10);     # x3 is Binomial with p=0.5 and n=10
                          # Watch the order!
  x4 ~ dexp(1/7.);        # x4 is exponential with tau=7 (r=1/tau=1/7)
}
", model)

# we pass the model to JAGS
jm <- jags.model(model)

# make the simulation, monitoring the four variables
chain <- coda.samples(jm, c("x1","x2","x3","x4"), n.iter=10000)

# plot the results
plot(chain)

# print the summaries
print(summary(chain))

# remove the temporary model file
system('rm -f tmp_model.bug')