title: How to Save a Coda Object in R
body: <p>I'm unsure of how to save a coda (mcmc.list) object in R. Others have asked similar questions, but I found that the answers given were not particularly clear. Ideally I'd like to save the coda object as an R.data file or a text file (e.g., csv), so that I can reimport it and analyze the JAGS chains without having to rerun the model (which takes about 30 minutes on my computer). Right now my coda object "coda.samples" looks like this:</p>
  
  <pre><code>str(coda.samples)
  List of 3
   $ : mcmc [1:3334, 1:1094] 0.904 0.977 0.927 0.945 0.905 ...
    ..- attr(*, "dimnames")=List of 2
    .. ..$ : chr [1:3334] "2001" "2011" "2021" "2031" ...
    .. ..$ : chr [1:1094] "alpha[1,1]" "alpha[2,1]" "alpha[1,2]" "alpha[2,2]" ...
    ..- attr(*, "mcpar")= num [1:3] 2001 35331 10
   $ : mcmc [1:3334, 1:1094] 0.824 0.866 0.839 0.832 1.032 ...
    ..- attr(*, "dimnames")=List of 2
    .. ..$ : chr [1:3334] "2001" "2011" "2021" "2031" ...
    .. ..$ : chr [1:1094] "alpha[1,1]" "alpha[2,1]" "alpha[1,2]" "alpha[2,2]" ...
    ..- attr(*, "mcpar")= num [1:3] 2001 35331 10
   $ : mcmc [1:3334, 1:1094] 0.956 0.944 0.895 0.809 1.064 ...
    ..- attr(*, "dimnames")=List of 2
    .. ..$ : chr [1:3334] "2001" "2011" "2021" "2031" ...
    .. ..$ : chr [1:1094] "alpha[1,1]" "alpha[2,1]" "alpha[1,2]" "alpha[2,2]" ...
    ..- attr(*, "mcpar")= num [1:3] 2001 35331 10
   - attr(*, "class")= chr "mcmc.list"
  </code></pre>
  
  <p>As you can see, it's a list of three matrices that contain 3334 estimates of 1094 parameters (i.e., 3 chains of length 3334). I'd like to store this coda object so that I can call it back into R without having to rerun the model over again each time. I also want to preserve the fact that there are three unique chains.</p>