Exporting data from R into WinBUGS’s “R/S-plus list format”

[This article was first published on Robert Grant's stats blog » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.

To leave a comment for the author, please follow the link and comment on their blog: Robert Grant's stats blog » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)