Users of the world’s favourite Bayesian analysis software WinBUGS will recognise the strange format in which data is supplied inside the GUI, generally in a text file looking something like this:
This is of course an R (or strictly speaking, S) language format, but it’s not how R views data, and although you can also supply the data in a fixed column width format, I have occasionally wondered how to export data from a bigger general analysis and data management package like R into that weird list format. If you start to think about it, you soon realise it isn’t simple. It hasn’t been an issue because you can just run WinBUGS from inside R, but this week I found I had to do it. I won’t bore you with details.
I found this webpage from Iowa State University which gives an R function called writeDatafileR. This works very nicely, producing a text file that you can then open in WinBUGS’s own GUI, and I am surprised it isn’t better known or on CRAN. It is apparently written by Terry Elrod but though I searched for Terry on Google and at Iowa State I couldn’t find out any more about him or her. So here’s a Pioneer-10-esque “thank you” into cyberspace that may one day find Terry.