## Introduction

• The code and data are provided to fully reproduce the examples and figurs in the book. They can be a good way to see what the code does. Different people have different styles of code. The code here is not supposed to be a model. The statistical analyses and graphs in the book are intended to be models for good practice, but the code here is meant to be simple with minimal dependencies.
• For R programming basics see Appendix A of Regression and Other Stories. If you want to learn more, see our recommendations for R programming and visualization with R.

• The folders below (ending /) point to the code (.R and .Rmd) and data folders (.csv or .txt) in github, and .html -files point to knitted notebooks.
• Most examples have cleaned data in .csv file in data subfolder for easy experimenting. For completeness and reproducibility, the data subfolders have also the raw data and *_setup.R file showing how the data pre-processing has been done (to do the exercises and follow along with the examples, you don’t need to worry about the setup code).
• For easy access to data sets, there is an R package rosdata. You can install it with a command remotes::install_github("avehtari/ROS-Examples",subdir = "rpackage"). Then you can access data, for example, as library(rosdata), data(wells), head(wells). You can get the list of data sets with ?rosdata.

• When running the notebooks, to avoid need to switch the working directory, rprojroot package is used to set the project root directory. The downloaded git repository can be placed anywhere you like and you can rename the ROS-Examples directory if you wish. When running the code, it is sufficient that the working directory is any directory in the ROS-Examples (or renamed). Running
library("rprojroot")
root<-has_file(".ROS-Examples-root")\$make_fix_file()

will find the file .ROS-Examples-root which is in the ROS-Examples directory, and will set the full path according to that. Then, for example,

wells <- read.csv(root("Arsenic/data","wells.csv"))

finds the wells.csv file, no matter where you have placed or renamed the ROS-Examples directory. When you switch to another example, there is no need to switch the working directory.