write.table
expects a data frame or a matrix (if you don't pass it one, it will try and coerce it). If you look at the structure of codaSamples
with e.g. str(codaSamples)
you'll see that it is a list object with elements which are lists or data frames or matrices (I don't know what it actually is). IF it is mixed like that, write.table
has no idea how to turn it into a csv.
If you want to select only the matrix you can find the name of the element with names(codaSamples)
or again from str(codaSamples)
and then do something like sample.mcmc <- codaSamples[['Matrix']]
or whatever the name is, then you should be able to save sample.mcmc
to a file just like you have.