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 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 the original source.

Contents and audience

This book contains all materials needed to teach a variety of introductory courses 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 Strings of text, 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) provides a general introduction to data literacy and reproducible research that is using R, but not focusing on 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.

Providing feedback

As this 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.

Linking and citing

Everyone likes being linked or cited. Feel free to adopt this book or parts of it to your own purposes, but please acknowledge its use in your own work. As the structure of the book’s chapters and sections may change, links should only use the base URL https://bookdown.org/hneth/ds4psy/.

To cite this book or the corresponding R package ds4psy (Neth, 2020), please use:

  • Neth, H. (2020). ds4psy: Data Science for Psychologists.
    Social Psychology and Decision Sciences, University of Konstanz, Germany.
    Textbook and R package (version 0.5.0, Sep 1, 2020).
    Retrieved from https://bookdown.org/hneth/ds4psy/.

A BibTeX entry for LaTeX users is:

  title = {ds4psy: Data Science for Psychologists},  
  author = {Hansjörg Neth},  
  year = {2020},  
  organization = {Social Psychology and Decision Sciences, University of Konstanz},  
  address = {Konstanz, Germany},  
  note = {Textbook and R package (version 0.5.0, Sep 1, 2020)},  
  url = {https://bookdown.org/hneth/ds4psy/}

The URL of the R package ds4psy is https://CRAN.R-project.org/package=ds4psy.


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 evaluate the popularity of its different chapters. The website does not collect any personal data of individual 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.20), circlize (0.4.9), coda (0.19.3), datasets (3.6.3), devtools (2.3.2), dplyr (1.0.2), ds4psy (, forcats (0.5.0), ggplot2 (3.3.2), graphics (3.6.3), grDevices (3.6.3), grid (3.6.3), here (0.1), jpeg (, knitr (1.30), 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.3), stats (3.6.3), stringr (1.4.0), tibble (3.0.3), tidyr (1.1.2), tidyverse (1.3.0), unikn (, usethis (1.6.3), 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-10-22 16:50:46 by hn.]


Neth, H. (2020). ds4psy: Data science for psychologists. Retrieved from https://CRAN.R-project.org/package=ds4psy

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