# Preface {.unnumbered}
## Is this book for me?
We've written this book for anyone interested in a working with Observational Medical Outcomes Partnership (OMOP) Common Data Model (CDM) instances using a tidyverse style approach. That is, human centered, consistent, composable, and inclusive (see [Tidy design principles](https://design.tidyverse.org/unifying.html) for more details on these principles).
New to R? We recommend you to take a look to [R for data science](https://r4ds.had.co.nz/) before reading this book. We assume that you have [R](https://cran.r-project.org) installed and together with an adequate Integrated Development Environment (IDE) such as [R Studio](https://posit.co/download/rstudio-desktop/) or [positron](https://positron.posit.co). See this [tutorial](https://rstudio-education.github.io/hopr/starting.html) if you need guidance on how to get started. The book uses multiple packages, that you will need to install see the list in the [R packages](TODO) section.
New to databases? We recommend you take a look at some web tutorials on SQL, such as [SQLBolt](https://sqlbolt.com/) or [SQLZoo](https://www.sqlzoo.net/wiki/SQL_Tutorial) to have a basic understanding of how databases work.
New to the OMOP CDM? We'd recommend you pare this book with [The Book of OHDSI](https://ohdsi.github.io/TheBookOfOhdsi/).
## How is the book organised?
The book is divided into two parts. The first half of the book is focused on the general principles for working with databases from R. In these chapters you will see how you can use familiar tidyverse-style code to build up analytic pipelines that start with data held in a database and end with your analytic results. The second half of the book is focused on working with data in the OMOP CDM format, a widely used data format for health care data. In these chapters you will see how to work with this data format using the general principles from the first half of the book along with a set of R packages that have been built for the OMOP CDM.
## Citation
Please if you found this book useful help us citing it:
```
Burn E, Black A, Raventós B, Guo Y, Du M, López-Güell K, Mercadé-Besora N,
Català M. Tidy R programming with the OMOP Common Data Model. GitHub; 2025.
https://github.com/oxford-pharmacoepi/Tidy-R-programming-with-OMOP
```
## License
```{=html}
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" alt="Creative Commons License" style="border-width:0"/></a> <br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
```
## Code
The source code for the book can be found at this [GitHub repository](https://github.com/oxford-pharmacoepi/Tidy-R-programming-with-OMOP), please star it if you found it useful.
## R Packages
This book is rendered automatically though [GitHub Actions](https://github.com/oxford-pharmacoepi/Tidy-R-programming-with-OMOP/blob/main/.github/workflows/publish.yml) using the following version of packages:
```{r, echo=FALSE}
explicitPkgs <- list.files(here::here(), pattern = ".qmd$", full.names = TRUE, recursive = TRUE) |>
purrr::map(\(x) {
lines <- paste0(readLines(x), collapse = " ")
regmatches(lines, gregexpr("library\\(([^)]+)\\)", lines)) |>
purrr::map(\(s) gsub("library\\(([^)]+)\\)", "\\1", s)) |>
unlist()
}) |>
unlist() |>
unique() |>
sort()
allPkgs <- renv::dependencies()$Package
# to decide if we want to include all the packages or only the packages that we
# use explicitly
explicitPkgs |>
unique() |>
purrr::map(\(pkg) {
d <- utils::packageDescription(pkg = pkg)
link <- d$URL |>
stringr::str_split_1(pattern = "[,\\s]+") |>
dplyr::first()
dplyr::tibble(
Package = pkg,
Version = d$Version,
Link = paste0("[🔗](", link, ")")
)
}) |>
dplyr::bind_rows() |>
dplyr::arrange(Package) |>
gt::gt() |>
gt::fmt_markdown("Link")
```
Note we only included the packages called explicitly in the book.