title: How to make write.table retain dimnames?
body: <p>I need to save a number of tables in a single CSV file and am having difficulty seeing how to retain dimension names. I searched SO and the closest I found was:
  <a href="https://stackoverflow.com/questions/12800784/how-to-get-dimnames-in-xtable-table-output">How to get dimnames in xtable.table output?</a>
  The problem he has with xtable is the problem I've got with write.table – dimnames exist in the table (and prop.table and ftable as well if I use that) but get dropped by write.table. I'm using write.table not write.csv for append=T.</p>
  
  <p>The dataset is from a survey and the aim is to create the complete set of crosstabs, with labelled axes. In this case, actual row/column labels are not important, only dimension labels. I'm new to R, so hope I haven't missed something obvious.</p>
  
  <pre><code>d&lt;-read.csv('dataset.csv')  # dataset with column headings, no row labels
  cat('BEGIN\n',file='xtabs.csv')
  for (i in 1:ncol(d)) {
      for (j in 1:ncol(d)) {
          cat(paste('\ni=',i,' j=',j,'\n'),file='xtabs.csv',append=T)
          t&lt;-table(d[,i],d[,j],dnn=c(names(d[i]),names(d[j])))
          pt&lt;-prop.table(t,1)
          write.table(pt,'xtabs.csv',sep=',',dec='.',row.names=F,col.names=F,append=T)
          print(pt)   # shows dimnames in the console as expected
      }
  }
  </code></pre>