The R2WinBUGS package facilitates the integration of WinBUGS, a software for Bayesian inference using Gibbs sampling, into the R statistical computing environment. It automatically writes data and scripts in a format compatible with WinBUGS for batch processing. After running WinBUGS, the package can read the results back into R, providing graphical summaries and convergence diagnostics, or users can use the coda package for further analysis. The package supports multiple Markov chains, allows for specifying initial values, and provides functions for data manipulation and model specification. Examples are provided to demonstrate how to use R2WinBUGS for educational testing experiments and childhood leukemia incidence studies. The implementation details of the bugs() function, which is the main interface for calling WinBUGS from R, are also described, including arguments for data preparation, model specification, and output handling.The R2WinBUGS package facilitates the integration of WinBUGS, a software for Bayesian inference using Gibbs sampling, into the R statistical computing environment. It automatically writes data and scripts in a format compatible with WinBUGS for batch processing. After running WinBUGS, the package can read the results back into R, providing graphical summaries and convergence diagnostics, or users can use the coda package for further analysis. The package supports multiple Markov chains, allows for specifying initial values, and provides functions for data manipulation and model specification. Examples are provided to demonstrate how to use R2WinBUGS for educational testing experiments and childhood leukemia incidence studies. The implementation details of the bugs() function, which is the main interface for calling WinBUGS from R, are also described, including arguments for data preparation, model specification, and output handling.