---
title: "Data Science for Psychologists (ds4psy)"
output: rmarkdown::html_vignette
pdf_document:
         latex_engine: xelatex
vignette: >
  %\VignetteIndexEntry{ds4psy}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r preamble-ds4psy, include = FALSE}
# Default chunk options:
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

# Some URLs (from ds4psy ebook): ----

# Posit connect cloud hosting:
url_posit_hneth <- "https://connect.posit.cloud/hneth/"

# (1) ds4psy: ------ 
url_ds4psy_book_old <- "https://bookdown.org/hneth/ds4psy/" # moved to:
url_ds4psy_book     <- "https://hneth-ds4psy.share.connect.posit.cloud/"
url_ds4psy_cran     <- "https://CRAN.R-project.org/package=ds4psy"

# (2) i2ds: ------ 
url_i2ds_book_old <- "https://bookdown.org/hneth/i2ds/" # moved to:
url_i2ds_book     <- "https://hneth-i2ds.share.connect.posit.cloud/"
```

<!-- ds4psy book link and logo (on right): -->
<a href="https://bookdown.org/hneth/ds4psy/">
<img src = "./../inst/images/logo.png" alt = "ds4psy" width = "160px" align = "right" style = "width: 160px; float: right; border:11;"/>
</a>


**Welcome** to the R package **ds4psy** &mdash; a software companion to the books and courses 
[Data Science for Psychologists](`r url_ds4psy_book`) and 
[Introduction to Data Science](https://bookdown.org/hneth/i2ds/). 


### R package {-}

The R package **ds4psy** provides datasets and functions used in books and courses that teach R and the basics of data science to a variety of audiences. 
Its source code is hosted at <https://github.com/hneth/ds4psy>. 


<!-- Corresponding textbooks: ds4psy vs. i2ds -->

### Textbooks {-}

The R package **[ds4psy](`r url_ds4psy_cran`)** is used by the following textbooks that are freely available at <`r url_posit_hneth`>:

- The **[ds4psy book](`r url_ds4psy_book`)** is available at <`r url_ds4psy_book`>  
- The **[i2ds book](`r url_i2ds_book`)** is available at <`r url_i2ds_book`> 

These books and courses introduce the principles and methods of data science for students of psychology and other biological or social sciences. 

<!-- Textbooks at bookdown vs. the Posit Connect cloud: -->

### Change of hosting service and URLs {-}

Both textbooks were originally hosted at <https://bookdown.org> (up to 2026-01-15). 
Static versions are still available at <`r url_ds4psy_book_old`> and <`r url_i2ds_book_old`>, respectively, but these are no longer updated.

Future versions will be hosted at <`r url_posit_hneth`>. 
Hence, visit <`r url_ds4psy_book`> and <`r url_i2ds_book`> for the most recent versions. 




## The ds4psy and i2ds books, courses, and R package 

The **ds4psy** 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. The **i2ds** book and corresponding courses provide similar contents in a more extensive and updated form. 

The **audience** of these materials 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. 

The R package **ds4psy** primarily provides datasets, but also functions for data generation and manipulation (e.g., of text and time data) and graphics that are used in the book and its exercises. All functions included in **ds4psy** are designed to be explicit and instructive, rather than efficient or elegant. 


## Installation

The current release of **ds4psy** is available from [CRAN](https://CRAN.R-project.org/) at <https://CRAN.R-project.org/package=ds4psy>:

```{r install_CRAN, echo = TRUE, eval = FALSE}
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](https://github.com) repository at <https://github.com/hneth/ds4psy/>: 

```{r install_github, echo = TRUE, eval = FALSE}
# install.packages('devtools')  # (if not installed yet)
devtools::install_github('hneth/ds4psy')
library('ds4psy')  # load to use the package
```


## Resources

<!-- i2ds book link and logo (on right): -->
<a href="https://bookdown.org/hneth/i2ds/">
<img src = "./../inst/images/i2ds_logo_1.png" alt = "i2ds" width = "160px" align = "right" style = "width: 160px; float: right; border:11;"/>
</a>

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

<!-- Current links: -->

- The current version of **[Introduction to Data Science](`r url_i2ds_book`)** is available online at <`r url_i2ds_book`>.

- A version of the **[Data science for psychologists](`r url_ds4psy_book`)** book is available online at <`r url_ds4psy_book`>.   

- The current R package **ds4psy** is available at <https://CRAN.R-project.org/package=ds4psy>.  


<!-- Background / origin: -->

These books and courses were originally based on the classic 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 <https://r4ds.had.co.nz/>)  

<!-- Our focus: base R before tidyverse -->

but provide more **base** R and less **tidyverse** content.


- For **ds4psy** sources, there are two **GitHub** repositories to be distinguished:  

    - The repository for the [ds4psy book](`r url_ds4psy_book`) is <https://github.com/hneth/ds4psy> (with an additional suffix `_book`). 

    - The repository for the [ds4psy package](https://github.com/hneth/ds4psy/) is <https://github.com/hneth/ds4psy>.  

<!-- - The current course syllabus is available at <http://rpository.com/ds4psy/>.    -->


## About

If you find these materials useful, or want to adopt or alter them for your purposes, please [let me know](https://spds.uni-konstanz.de//hans-neth). 


### Citation

To cite **ds4psy** in derivations and publications, please use:

- Neth, H. (2026). ds4psy: Data Science for Psychologists.  
Social Psychology and Decision Sciences, University of Konstanz, Germany.  
Textbook and R package (version 1.3.0, April 22, 2026).  
Retrieved from <`r url_ds4psy_book`>.  
[https://doi.org/10.5281/zenodo.7229812](https://doi.org/10.5281/zenodo.7229812)  


<!-- BibTeX reference: -->

A **BibTeX** entry for LaTeX users is: 

```{r pkg-citation, echo = TRUE, eval = FALSE, comment = "", highlight = FALSE}
@Manual{ds4psy,
  title = {ds4psy: Data Science for Psychologists},
  author = {Hansjörg Neth},
  year = {2026},
  organization = {Social Psychology and Decision Sciences, University of Konstanz},
  address = {Konstanz, Germany},
  note = {R package (version 1.3.0, April 22, 2026); Textbook at <https://hneth-ds4psy.share.connect.posit.cloud/>.},
  url = {https://CRAN.R-project.org/package=ds4psy},
  doi = {10.5281/zenodo.7229812}
}
```


### License

<!-- (a) Use online image: -->

<!-- <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a> -->

<!-- (b) Use local image: -->

<a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src = "./../inst/images/CC_BY_NC_SA.png" /></a>


<!-- License text:  -->

<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">**Data science for psychologists** (**ds4psy**)</span> by <a xmlns:cc="https://creativecommons.org/ns#" href="https://neth.de" property="cc:attributionName" rel="cc:attributionURL">Hansjörg Neth</a> is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>. 


<!-- Update: -->

[Updated `r format(Sys.time(), "%Y-%m-%d")` by [hn](https://neth.de).]  

<!-- eof. -->
