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

November 27, 2012

(This article was first published on Robert Grant's stats blog » R, and kindly contributed to R-bloggers)

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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


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)