title: JAGS, rjags: "Error in file(modfile, "rt") : cannot open the connection"
body: <p>I have recently started working with JAGS and invoking it inside of R. I finally got jags linked to R with the code </p>
  
  <pre><code>install.packages("rjags")
  library(rjags)
  </code></pre>
  
  <p>and got the output </p>
  
  <pre><code>Linked to JAGS 3.4.0
  Loaded modules: basemod,bugs
  </code></pre>
  
  <p>I also saved the JAGS model data in a separate file in the BUG format (like I was taught).</p>
  
  <p>When I tried to run my data through however I keep getting the error messages:</p>
  
  <pre><code>Error in file(modfile, "rt") : cannot open the connection
  In addition: Warning message:
  In file(modfile, "rt") :
    cannot open file 'age_problem.bug': No such file or directory
  Error in jags.model("age_problem.bug", data = list(X = X, N = length(X)),  : 
    Cannot open model file "age_problem.bug"
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Error in update(jags, 1000) : object 'jags' not found
  </code></pre>
  
  <p>Is there some crucial step that I am missing? </p>
  
  <p>EDIT: Code for example problem</p>
  
  <pre><code>N &lt;- 1000
  x &lt;- rnorm(N, 0, 5)
  
  write.table(x,
              file = 'example1.data',
              row.names = FALSE,
              col.names = FALSE)
  
  library('rjags')
  
  jags &lt;- jags.model('example1.bug',
                     data = list('x' = x,
                                 'N' = N),
                     n.chains = 4,
                     n.adapt = 100)
  
  update(jags, 1000)
  
  jags.samples(jags,
               c('mu', 'tau'),
               1000)
  </code></pre>
  
  <p>JAGS Model:</p>
  
  <pre><code>model {for (i in 1:N) {
          x[i] ~ dnorm(mu, tau)}
      mu ~ dnorm(0, .0001)
      tau &lt;- pow(sigma, -2)
      sigma ~ dunif(0, 100)}
  </code></pre>