About ds4psy

This book was first started to summarize and elaborate upon key chapters of the R for Data Science (Wickham & Grolemund, 2017) textbook. As many of my students struggled with this text, I began selecting and summarizing essential concepts and commands and adapted my examples and exercises to the needs of students in psychology and other biological and social sciences. By now, most chapters here contain a mix of summaries and additional materials, which typically complement the tidyverse perspective embraced by its original source.

Contents and audience

Since 2020, this book contains all materials needed to teach an introductory course on data science for undergraduate students of psychology and related fields. Depending on student needs and the length of the teaching period, some of the more specialized chapters (e.g., Chapter 9 on Text data, Chapter 10 on Dates and times, or Appendix E on regular expressions) can be skipped and used as the basis of a more advanced curriculum. By contrast, combining the chapters of Part I and Part IV with some appendices (e.g., Appendix D on using colors in R and Appendix F on using R Markdown) is suited to provide an introduction to data literacy and reproducible research in R that is not limited to data science or the packages of the tidyverse.

The book was conceived with students of psychology in mind, but its materials and examples engage and motivate students from different fields to apply computational tools to solve challenging problems. Hopefully, students from a variety of disciplines will welcome the summaries of essential commands and find solving the exercises both enjoyable and enlightning.


As the text is still being revised and data science is a dynamic field, it is likely that the current version contains some typos and mistakes. Please email me (as h.neth at uni.kn) to report any errors, possible improvements, or any other feedback or observations that you are willing to share.


Creative Commons License

Data science for psychologists (ds4psy) by Hansjörg Neth is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


The HTML-version of this book uses Google Analytics to know how many people are reading the book and to evaluate the popularity of its chapters. The website does not collect any personal data of its users.


This book was generated using R version 3.6.3 (2020-02-29) and the following packages:

  • base (3.6.3), BayesFactor (, bookdown (0.18), circlize (0.4.9), coda (0.19.3), datasets (3.6.3), devtools (2.3.0), dplyr (0.8.5), ds4psy (, forcats (0.5.0), ggplot2 (3.3.1), graphics (3.6.3), grDevices (3.6.3), grid (3.6.3), here (0.1), jpeg (, knitr (1.28), lubridate (1.7.9), Matrix (1.2.18), methods (3.6.3), purrr (0.3.4), RColorBrewer (1.1.2), readr (1.3.1), rmarkdown (2.1), stats (3.6.3), stringr (1.4.0), tibble (3.0.1), tidyr (1.1.0), tidyverse (1.3.0), unikn (, usethis (1.6.1), utils (3.6.3), viridis (0.5.1), viridisLite (0.3.0), yarrr (0.1.5).

Thanks to all package authors and the R community for making this book possible!


[85_coda.Rmd updated on 2020-07-30 20:25:01 by hn.]


Wickham, H., & Grolemund, G. (2017). R for data science: Import, tidy, transform, visualize, and model data. Retrieved from http://r4ds.had.co.nz