ds4psy v0.1.0


Monthly downloads



Data Science for Psychologists

All data sets required for the examples and exercises in the book "Data Science for Psychologists" (by Hansjoerg Neth, Konstanz University, 2019), freely available at <https://bookdown.org/hneth/ds4psy/>. The book and course introduce principles and methods of data science to students of psychology and other biological or social sciences. The 'ds4psy' package primarily provides datasets, but also functions for graphics and text-manipulation that are used in the book and its exercises.



Data Science for Psychologists (ds4psy)

Welcome to the R package ds4psy — a software companion to the book and course
Data Science for Psychologists.

This R package provides datasets and functions used in the ds4psy book and course. The book and course introduce the principles and methods of data science for students of psychology and other biological or social sciences.


The current release of ds4psy is available from CRAN at https://CRAN.R-project.org/package=ds4psy:

install.packages('ds4psy')  # install ds4psy from CRAN client
library('ds4psy')           # load to use the package

The current development version can be installed from its GitHub repository at https://github.com/hneth/ds4psy/:

# install.packages('devtools')  # (if not installed yet)
library('ds4psy')  # load to use the package

The most recent version of the ds4psy book is freely available at https://bookdown.org/hneth/ds4psy/.

Course Coordinates



This book and course provide an introduction to data science that is tailored to the needs of psychologists, but is also suitable for students of the humanities and other biological or social sciences. This audience typically has some knowledge of statistics, but rarely an idea how data is prepared and shaped to allow for statistical testing. By using various data types and working with many examples, we teach tools for transforming, summarizing, and visualizing data. By keeping our eyes open for the perils of misleading representations, the book fosters fundamental skills of data literacy and cultivates reproducible research practices that enable and precede any practical use of statistics.


Students of psychology and other social sciences are trained to analyze data. But the data they learn to work with (e.g., in courses on statistics and empirical research methods) is typically provided to them and structured in a (rectangular or "tidy") format that presupposes many steps of data processing regarding the aggregation and spatial layout of variables. When beginning to collect their own data, students inevitably struggle with these pre-processing steps which — even for experienced data scientists — tend to require more time and effort than choosing and conducting statistical tests.

This course develops the foundations of data analysis that allow students to collect data from real-world sources and transform and shape such data to answer scientific and practical questions. Although there are many good introductions to data science (e.g., Grolemund & Wickham, 2017) they typically do not take into account the special needs — and often anxieties and reservations — of psychology students. As social scientists are not computer scientists, we introduce new concepts and commands without assuming a mathematical or computational background. Adopting a task-oriented perspective, we begin with a specific problem and then solve it with some combination of data collection, manipulation, and visualization.


Our main goal is to develop a set of useful skills in analyzing real-world data and conducting reproducible research. Upon completing this course, you will be able to use R to read, transform, analyze, and visualize data of various types. Many interactive exercises allow students to continuously check their understanding, practice their skills, and monitor their progress.


This course assumes some basic familiarity with statistics and the R programming language, but enthusiastic programming novices are also welcome.


This package and the corresponding book are still being developed and are updated as new materials become available.


Course materials

The script was originally based on the following textbook:

  • Wickham, H., & Grolemund, G. (2017). R for data science: Import, tidy, transform, visualize, and model data. Sebastopol, Canada: O'Reilly Media, Inc. [Available online at http://r4ds.had.co.nz.]


Please install the following open-source programs on your computer:

# Tidyverse packages: 

# Course packages: 
install.packages("ds4psy", "unikn")

# Additional data packages (optional): 
install.packages("nycflights13", "babynames", "fueleconomy")

Other resources



R manuals and books


If you find these materials useful, or want to adopt or alter them for your purposes, please let me know.


To cite ds4psy in derivations and publications, please use:

  • Neth, H. (2019). ds4psy: Data Science for Psychologists. Social Psychology and Decision Sciences, University of Konstanz, Germany. Textbook and computer software (R package version 0.1.0, August 9, 2019). 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 = {2019},
  organization = {Social Psychology and Decision Sciences, University of Konstanz},
  address = {Konstanz, Germany},
  note = {Textbook and R package (version 0.1.0, August 9, 2019)},
  url = {https://bookdown.org/hneth/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.

[Updated 2019-08-09 by hn.]

Functions in ds4psy

Name Description
plot_n Plot n tiles.
pal_ds4psy ds4psy default color palette.
outliers Outlier data.
table6 Data table6.
l33t_rul35 l33t_rul35 provides rules for translating into leet/l33t slang.
table7 Data table7.
falsePosPsy_all False Positive Psychology data.
pal_n_sq Get n-by-n dedicated colors of a color palette.
pi_100k Data: 100k digits of pi.
t3 Data table t3.
posPsy_p_info Positive Psychology: Participant data.
posPsy_wide Positive Psychology: All corrected data (in wide format).
t4 Data table t4.
posPsy_AHI_CESD Positive Psychology: AHI CESD data.
posPsy_long Positive Psychology: AHI CESD corrected data (in long format).
data_t2 Data table data_t2.
plot_tiles Plot n-by-n tiles.
transl33t transl33t text into leet slang (using stringr).
theme_ds4psy ds4psy default plot theme (using ggplot2 and unikn).
plot_fun A function to plot some plot.
tb Data table tb.
plot_fn A function to plot a plot.
table8 Data table8.
data_t1_tab Data import data_t1_tab.
data_t4 Data table data_t4.
data_t3 Data table data_t3.
ds4psy.guide Opens user guide of the ds4psy package.
data_1 Data import data_1.
exp_wide Data exp_wide.
data_2 Data import data_2.
data_t1 Data table data_t1.
data_t1_de Data import data_t1_de.
No Results!

Vignettes of ds4psy

No Results!

Last month downloads


Type Package
Date 2019-08-09
Collate 'data.R' 'color_fun.R' 'text_fun.R' 'data_fun.R' 'theme_fun.R' 'plot_fun.R' 'util_fun.R' 'start.R'
Encoding UTF-8
LazyData true
License CC BY-SA 4.0
URL https://bookdown.org/hneth/ds4psy/, https://github.com/hneth/ds4psy/
BugReports https://github.com/hneth/ds4psy/issues
VignetteBuilder knitr
RoxygenNote 6.1.1
Language en-US
NeedsCompilation no
Packaged 2019-08-09 17:52:11 UTC; hneth
Repository CRAN
Date/Publication 2019-08-10 09:30:10 UTC

Include our badge in your README