For this exercise, please try to reproduce the results from Study 1 of the associated paper (Joel, Teper, & MacDonald, 2014). The PDF of the paper is included in the same folder as this Rmd file.

Methods summary:

In study 1, 150 introductory psychology students were randomly assigned to a “real” or a “hypothetical” condition. In the real condition, participants believed that they would have a real opportuniy to connect with potential romantic partners. In the hypothetical condition, participants simply imagined that they are on a date. All participants were required to select their favorite profile and answer whether they were willing to exchange contact information.


Target outcomes:

Below is the specific result you will attempt to reproduce (quoted directly from the results section of Study 1):

We next tested our primary hypothesis that participants would be more reluctant to reject the unattractive date when they believed the situation to be real rather than hypothetical. Only 10 of the 61 participants in the hypothetical condition chose to exchange contact information with the unattractive potential date (16%). In contrast, 26 of the 71 participants in the real condition chose to exchange contact information (37%). A chi-square test of independence indicated that participants were significantly less likely to reject the unattractive potential date in the real condition compared with the hypothetical condition, X^2(1, N = 132) = 6.77, p = .009.


Step 1: Load packages

#install.packages("labelled")
library(tidyverse) # for data munging
library(knitr) # for kable table formating
library(haven) # import and export 'SPSS', 'Stata' and 'SAS' Files
library(readxl) # import excel files

# #optional packages:
library(broom)
library(labelled) # converts SPSS's labelled to R's factor 

Step 2: Load data

# Just Study 1
d <- read_sav('data/Empathy Gap Study 1 data.sav')

Step 3: Tidy data

str(d)
## tibble [132 × 125] (S3: tbl_df/tbl/data.frame)
##  $ ID                            : num [1:132] 53 93 83 27 6 116 24 127 32 73 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment1                   : num [1:132] 3 5 3 2 3 4 6 6 5 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment2                   : num [1:132] 4 1 6 6 6 7 5 2 5 6 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment3                   : num [1:132] 5 3 3 5 3 5 6 6 5 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment4                   : num [1:132] 3 4 6 2 5 6 3 5 4 6 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment5                   : num [1:132] 2 2 5 5 5 6 2 4 4 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment6                   : num [1:132] 3 2 4 5 5 6 2 5 2 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment7                   : num [1:132] 5 2 2 6 1 3 6 4 6 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment8                   : num [1:132] 2 2 2 2 5 3 3 4 1 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment9                   : num [1:132] 4 5 3 2 3 3 7 6 5 6 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment10                  : num [1:132] 3 2 6 2 3 4 1 1 1 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment11                  : num [1:132] 5 3 5 5 5 6 6 6 6 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment12                  : num [1:132] 5 3 6 4 5 7 6 6 5 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment13                  : num [1:132] 5 3 2 1 3 3 2 5 5 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment14                  : num [1:132] 2 2 3 4 5 2 2 1 4 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment15                  : num [1:132] 4 3 5 3 5 2 2 3 2 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment16                  : num [1:132] 3 2 3 2 3 2 6 2 NA 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment17                  : num [1:132] 3 3 6 4 5 6 4 4 6 6 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment18                  : num [1:132] 2 3 5 3 3 5 3 2 NA 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment19                  : num [1:132] 5 3 5 5 3 4 5 5 NA 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment20                  : num [1:132] 3 3 2 2 3 3 3 4 2 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment21                  : num [1:132] 4 NA 3 6 4 6 6 4 NA 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment22                  : num [1:132] 3 NA 3 3 3 6 5 5 2 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment23                  : num [1:132] 3 2 3 3 5 3 3 2 5 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment24                  : num [1:132] 4 NA 3 5 6 4 3 4 NA 6 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment25                  : num [1:132] 3 NA 5 4 5 2 3 1 3 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment26                  : num [1:132] 4 4 6 1 5 6 2 4 5 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment27                  : num [1:132] 3 5 5 2 5 2 4 3 2 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment28                  : num [1:132] 5 4 3 2 3 3 5 6 NA 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment29                  : num [1:132] 3 NA 3 2 5 5 3 6 NA 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment30                  : num [1:132] 5 3 6 5 5 7 5 1 5 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment31                  : num [1:132] 3 NA 2 2 3 2 5 1 1 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment32                  : num [1:132] 5 NA 5 3 5 6 2 1 3 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment33                  : num [1:132] 2 7 5 5 3 3 7 1 5 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment34                  : num [1:132] 2 NA 3 2 5 4 2 7 1 6 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment35                  : num [1:132] 2 NA 5 4 2 3 6 4 2 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ attachment36                  : num [1:132] 5 5 3 3 2 5 5 5 NA 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ FOBA1                         : num [1:132] 2 1 5 2 4 5 2 4 2 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ FOBA2                         : num [1:132] 1 1 5 1 1 1 1 1 1 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ FOBA3                         : num [1:132] 1 1 5 3 1 4 1 3 1 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ FOBA4                         : num [1:132] 3 1 5 5 5 4 4 1 1 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ FOBA5                         : num [1:132] 1 4 5 3 1 5 4 5 1 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ FOBA6                         : num [1:132] 2 5 5 4 1 4 4 3 1 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy1                      : num [1:132] 2 3 4 4 4 4 5 5 4 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy2                      : num [1:132] 5 3 3 5 4 4 4 3 4 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy3                      : num [1:132] 1 4 1 3 2 5 2 2 2 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy4                      : num [1:132] 2 2 2 1 2 2 1 2 3 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy5                      : num [1:132] 4 3 5 4 5 4 4 5 4 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy6                      : num [1:132] 4 NA 5 5 4 5 3 5 3 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy7                      : num [1:132] 4 5 2 1 2 1 4 1 2 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy8                      : num [1:132] 4 NA 2 3 3 3 4 3 5 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy9                      : num [1:132] 4 5 3 5 4 5 4 4 5 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy10                     : num [1:132] 4 4 5 5 4 4 5 5 4 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy11                     : num [1:132] 4 NA 4 4 4 5 5 2 3 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy12                     : num [1:132] 3 2 1 1 2 2 2 3 1 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy13                     : num [1:132] 4 1 2 2 2 2 1 3 2 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy14                     : num [1:132] 3 1 1 1 3 2 1 1 2 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy15                     : num [1:132] 1 4 2 3 2 4 2 3 4 4 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy16                     : num [1:132] 4 4 4 4 4 5 4 5 2 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy17                     : num [1:132] 4 NA 5 5 4 5 4 3 5 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy18                     : num [1:132] 1 1 2 1 2 1 1 1 1 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy19                     : num [1:132] 1 NA 2 2 2 3 3 2 3 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy20                     : num [1:132] 1 NA 4 5 4 5 4 3 4 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy21                     : num [1:132] 1 NA 3 4 4 4 3 3 4 5 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy22                     : num [1:132] 5 NA 4 5 5 4 4 5 5 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy23                     : num [1:132] 1 NA 4 4 4 4 5 5 2 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy24                     : num [1:132] 2 NA 4 2 4 3 3 3 4 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy25                     : num [1:132] 4 NA 3 3 3 5 2 1 1 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy26                     : num [1:132] 4 4 3 5 4 4 3 4 3 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy27                     : num [1:132] 3 NA 4 3 3 3 4 4 4 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ empathy28                     : num [1:132] 4 2 2 3 4 4 3 3 3 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ age                           : num [1:132] 18 18 20 18 19 18 19 19 18 22 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ livedincanada                 : num [1:132] 3 4 4 4 1 4 2 4 4 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ orientation                   : num [1:132] 1 0 1 0 0 0 0 1 NA 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ inrel                         : num [1:132] 2 2 2 2 2 2 2 2 2 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ longterm                      : num [1:132] 2 2 1 1 2 2 1 2 1 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ dating                        : num [1:132] 1 2 1 1 2 1 1 1 1 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ shortterm                     : num [1:132] 1 1 2 2 1 2 2 1 1 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ intimate                      : num [1:132] 2 2 2 2 2 2 2 1 2 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ otheropen                     : num [1:132] 2 2 2 2 2 2 2 2 2 2 ...
##   ..- attr(*, "label")= chr "other/open"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ drink                         : num [1:132] 4 2 2 1 1 2 1 2 1 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ children                      : num [1:132] 1 4 2 1 1 1 2 1 1 3 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ responseq1                    : num [1:132] 4 2 3 1 5 3 3 1 3 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ responseq2                    : num [1:132] 4 3 4 2 4 3 4 1 3 1 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ responseq3                    : num [1:132] 4 3 4 2 3 4 4 2 4 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ responseq4                    : num [1:132] 4 3 4 3 4 4 4 3 4 2 ...
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ reasontrue1                   : num [1:132] 3 3 3 2 3 3 4 3 2 1 ...
##   ..- attr(*, "label")= chr "self"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ motives1                      : num [1:132] 3 3 2 1 3 3 3 3 2 1 ...
##   ..- attr(*, "label")= chr "self"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ reasontrue2                   : num [1:132] 4 4 5 1 4 4 5 4 5 3 ...
##   ..- attr(*, "label")= chr "other"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ motives2                      : num [1:132] 3 NA 4 1 4 4 4 1 5 1 ...
##   ..- attr(*, "label")= chr "other"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ reasontrue3                   : num [1:132] 4 2 3 2 4 3 4 1 2 1 ...
##   ..- attr(*, "label")= chr "self"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ motives3                      : num [1:132] 4 NA 4 2 4 3 3 1 2 1 ...
##   ..- attr(*, "label")= chr "self"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ reasontrue4                   : num [1:132] 4 2 5 1 4 4 5 1 5 1 ...
##   ..- attr(*, "label")= chr "other"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ motives4                      : num [1:132] 3 NA 4 1 4 4 4 1 5 1 ...
##   ..- attr(*, "label")= chr "other"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ reasontrue5                   : num [1:132] 3 2 4 2 3 3 3 3 3 1 ...
##   ..- attr(*, "label")= chr "self"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ motives5                      : num [1:132] 3 NA 3 3 3 3 2 3 3 1 ...
##   ..- attr(*, "label")= chr "self"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ reasontrue6                   : num [1:132] 3 2 5 1 4 4 4 4 5 3 ...
##   ..- attr(*, "label")= chr "other"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ motives6                      : num [1:132] 3 NA 4 1 4 4 4 4 5 1 ...
##   ..- attr(*, "label")= chr "other"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##  $ reasontrue7                   : num [1:132] 4 2 2 1 4 2 1 1 3 2 ...
##   ..- attr(*, "label")= chr "self"
##   ..- attr(*, "format.spss")= chr "F11.0"
##   ..- attr(*, "display_width")= int 11
##   [list output truncated]
names(d)
##   [1] "ID"                             "attachment1"                   
##   [3] "attachment2"                    "attachment3"                   
##   [5] "attachment4"                    "attachment5"                   
##   [7] "attachment6"                    "attachment7"                   
##   [9] "attachment8"                    "attachment9"                   
##  [11] "attachment10"                   "attachment11"                  
##  [13] "attachment12"                   "attachment13"                  
##  [15] "attachment14"                   "attachment15"                  
##  [17] "attachment16"                   "attachment17"                  
##  [19] "attachment18"                   "attachment19"                  
##  [21] "attachment20"                   "attachment21"                  
##  [23] "attachment22"                   "attachment23"                  
##  [25] "attachment24"                   "attachment25"                  
##  [27] "attachment26"                   "attachment27"                  
##  [29] "attachment28"                   "attachment29"                  
##  [31] "attachment30"                   "attachment31"                  
##  [33] "attachment32"                   "attachment33"                  
##  [35] "attachment34"                   "attachment35"                  
##  [37] "attachment36"                   "FOBA1"                         
##  [39] "FOBA2"                          "FOBA3"                         
##  [41] "FOBA4"                          "FOBA5"                         
##  [43] "FOBA6"                          "empathy1"                      
##  [45] "empathy2"                       "empathy3"                      
##  [47] "empathy4"                       "empathy5"                      
##  [49] "empathy6"                       "empathy7"                      
##  [51] "empathy8"                       "empathy9"                      
##  [53] "empathy10"                      "empathy11"                     
##  [55] "empathy12"                      "empathy13"                     
##  [57] "empathy14"                      "empathy15"                     
##  [59] "empathy16"                      "empathy17"                     
##  [61] "empathy18"                      "empathy19"                     
##  [63] "empathy20"                      "empathy21"                     
##  [65] "empathy22"                      "empathy23"                     
##  [67] "empathy24"                      "empathy25"                     
##  [69] "empathy26"                      "empathy27"                     
##  [71] "empathy28"                      "age"                           
##  [73] "livedincanada"                  "orientation"                   
##  [75] "inrel"                          "longterm"                      
##  [77] "dating"                         "shortterm"                     
##  [79] "intimate"                       "otheropen"                     
##  [81] "drink"                          "children"                      
##  [83] "responseq1"                     "responseq2"                    
##  [85] "responseq3"                     "responseq4"                    
##  [87] "reasontrue1"                    "motives1"                      
##  [89] "reasontrue2"                    "motives2"                      
##  [91] "reasontrue3"                    "motives3"                      
##  [93] "reasontrue4"                    "motives4"                      
##  [95] "reasontrue5"                    "motives5"                      
##  [97] "reasontrue6"                    "motives6"                      
##  [99] "reasontrue7"                    "motives7"                      
## [101] "reasontrue8"                    "motives8"                      
## [103] "suspicious"                     "selfattractive"                
## [105] "otherattractive"                "EmpathyPTtot"                  
## [107] "EmpathyFStot"                   "EmpathyECtot"                  
## [109] "EmpathyPDtot"                   "fobstot"                       
## [111] "attachmentavoidance"            "attachmentanxiety"             
## [113] "stateguilttot"                  "stateempathytot"               
## [115] "excitementtot"                  "compatibilitytot"              
## [117] "very_otherfocused"              "less_otherfocused"             
## [119] "gender"                         "genderXcondition"              
## [121] "REQUIRED_VARIABLES_START_BELOW" "condition"                     
## [123] "exchangeinfo"                   "otherfocused_motives"          
## [125] "selffocused_motives"
sapply(d, function(x) attr(x, "label"))
## $ID
## NULL
## 
## $attachment1
## NULL
## 
## $attachment2
## NULL
## 
## $attachment3
## NULL
## 
## $attachment4
## NULL
## 
## $attachment5
## NULL
## 
## $attachment6
## NULL
## 
## $attachment7
## NULL
## 
## $attachment8
## NULL
## 
## $attachment9
## NULL
## 
## $attachment10
## NULL
## 
## $attachment11
## NULL
## 
## $attachment12
## NULL
## 
## $attachment13
## NULL
## 
## $attachment14
## NULL
## 
## $attachment15
## NULL
## 
## $attachment16
## NULL
## 
## $attachment17
## NULL
## 
## $attachment18
## NULL
## 
## $attachment19
## NULL
## 
## $attachment20
## NULL
## 
## $attachment21
## NULL
## 
## $attachment22
## NULL
## 
## $attachment23
## NULL
## 
## $attachment24
## NULL
## 
## $attachment25
## NULL
## 
## $attachment26
## NULL
## 
## $attachment27
## NULL
## 
## $attachment28
## NULL
## 
## $attachment29
## NULL
## 
## $attachment30
## NULL
## 
## $attachment31
## NULL
## 
## $attachment32
## NULL
## 
## $attachment33
## NULL
## 
## $attachment34
## NULL
## 
## $attachment35
## NULL
## 
## $attachment36
## NULL
## 
## $FOBA1
## NULL
## 
## $FOBA2
## NULL
## 
## $FOBA3
## NULL
## 
## $FOBA4
## NULL
## 
## $FOBA5
## NULL
## 
## $FOBA6
## NULL
## 
## $empathy1
## NULL
## 
## $empathy2
## NULL
## 
## $empathy3
## NULL
## 
## $empathy4
## NULL
## 
## $empathy5
## NULL
## 
## $empathy6
## NULL
## 
## $empathy7
## NULL
## 
## $empathy8
## NULL
## 
## $empathy9
## NULL
## 
## $empathy10
## NULL
## 
## $empathy11
## NULL
## 
## $empathy12
## NULL
## 
## $empathy13
## NULL
## 
## $empathy14
## NULL
## 
## $empathy15
## NULL
## 
## $empathy16
## NULL
## 
## $empathy17
## NULL
## 
## $empathy18
## NULL
## 
## $empathy19
## NULL
## 
## $empathy20
## NULL
## 
## $empathy21
## NULL
## 
## $empathy22
## NULL
## 
## $empathy23
## NULL
## 
## $empathy24
## NULL
## 
## $empathy25
## NULL
## 
## $empathy26
## NULL
## 
## $empathy27
## NULL
## 
## $empathy28
## NULL
## 
## $age
## NULL
## 
## $livedincanada
## NULL
## 
## $orientation
## NULL
## 
## $inrel
## NULL
## 
## $longterm
## NULL
## 
## $dating
## NULL
## 
## $shortterm
## NULL
## 
## $intimate
## NULL
## 
## $otheropen
## [1] "other/open"
## 
## $drink
## NULL
## 
## $children
## NULL
## 
## $responseq1
## NULL
## 
## $responseq2
## NULL
## 
## $responseq3
## NULL
## 
## $responseq4
## NULL
## 
## $reasontrue1
## [1] "self"
## 
## $motives1
## [1] "self"
## 
## $reasontrue2
## [1] "other"
## 
## $motives2
## [1] "other"
## 
## $reasontrue3
## [1] "self"
## 
## $motives3
## [1] "self"
## 
## $reasontrue4
## [1] "other"
## 
## $motives4
## [1] "other"
## 
## $reasontrue5
## [1] "self"
## 
## $motives5
## [1] "self"
## 
## $reasontrue6
## [1] "other"
## 
## $motives6
## [1] "other"
## 
## $reasontrue7
## [1] "self"
## 
## $motives7
## [1] "self"
## 
## $reasontrue8
## [1] "other"
## 
## $motives8
## [1] "other"
## 
## $suspicious
## NULL
## 
## $selfattractive
## NULL
## 
## $otherattractive
## NULL
## 
## $EmpathyPTtot
## NULL
## 
## $EmpathyFStot
## NULL
## 
## $EmpathyECtot
## NULL
## 
## $EmpathyPDtot
## NULL
## 
## $fobstot
## NULL
## 
## $attachmentavoidance
## NULL
## 
## $attachmentanxiety
## NULL
## 
## $stateguilttot
## NULL
## 
## $stateempathytot
## NULL
## 
## $excitementtot
## NULL
## 
## $compatibilitytot
## NULL
## 
## $very_otherfocused
## [1] "four other-focused items that are strongly about the other"
## 
## $less_otherfocused
## [1] "four other-focused items that are more about own affect"
## 
## $gender
##   men women 
##     0     1 
## 
## $genderXcondition
## NULL
## 
## $REQUIRED_VARIABLES_START_BELOW
## [1] "See below for variables required for analyses in paper"
## 
## $condition
## [1] "Independent variable - hypothetical vs. real condition"
## 
## $exchangeinfo
## [1] "Key DV- whether or not participant agreed to exchange contact info"
## 
## $otherfocused_motives
## [1] "eight other-focused items"
## 
## $selffocused_motives
## [1] "eight self-focused items"
#clean vars
cond_raw <- as.character(haven::as_factor(d$condition))
exch_raw <- as.character(haven::as_factor(d$exchangeinfo))

unique(cond_raw); unique(exch_raw)
## [1] "real"         "hypothetical"
## [1] "yes" "no"
to_low <- function(x) trimws(tolower(x))
cond <- to_low(cond_raw)
exch <- to_low(exch_raw)

#two levels 
cond[grepl("hyp", cond)]  <- "hypothetical"
cond[grepl("^real$", cond)] <- "real"

exch[grepl("^(yes|exchange|accepted|agree|agreed)$", exch)] <- "yes"
exch[grepl("^(no|reject|decline|refuse|refused|did not exchange)$", exch)] <- "no"

#factors
keep <- !is.na(cond) & !is.na(exch) & cond %in% c("hypothetical","real") & exch %in% c("no","yes")
dat  <- data.frame(condition = factor(cond[keep], levels = c("hypothetical","real")),
                   exchanged = factor(exch[keep], levels = c("no","yes")))
nrow(dat)  # should be 132
## [1] 132

Step 4: Run analysis

Descriptive statistics

Only 10 of the 61 participants in the hypothetical condition chose to exchange contact information with the unattractive potential date (16%). In contrast, 26 of the 71 participants in the real condition chose to exchange contact information (37%).

# reproduce the above results here
# 2x2 counts
xt <- table(dat$condition, dat$exchanged)
xt
##               
##                no yes
##   hypothetical 51  10
##   real         45  26
# per-condition totals and yes counts/percentages
totals <- rowSums(xt)
yes    <- xt[,"yes"]
perc   <- round(100 * yes / totals)

data.frame(condition = rownames(xt),
           yes = as.integer(yes),
           total = as.integer(totals),
           percent_yes = perc)
##                 condition yes total percent_yes
## hypothetical hypothetical  10    61          16
## real                 real  26    71          37

Inferential statistics

A chi-square test of independence indicated that participants were significantly less likely to reject the unattractive potential date in the real condition compared with the hypothetical condition, X^2(1, N = 132) = 6.77, p = .009.

Hint: if you are using the function chisq.test(), make sure to set the continuity correction to false (“correct = FALSE”) since sample size is greater than 20.

# reproduce the above results here
stats::chisq.test(xt, correct = FALSE)
## 
##  Pearson's Chi-squared test
## 
## data:  xt
## X-squared = 6.7674, df = 1, p-value = 0.009284
c(
  statistic = unname(stats::chisq.test(xt, correct = FALSE)$statistic),
  df        = unname(stats::chisq.test(xt, correct = FALSE)$parameter),
  p_value   = unname(stats::chisq.test(xt, correct = FALSE)$p.value),
  N         = sum(xt)
)
##    statistic           df      p_value            N 
##   6.76737474   1.00000000   0.00928393 132.00000000

Step 5: Reflection

Were you able to reproduce the results you attempted to reproduce? If not, what part(s) were you unable to reproduce?

Yes

How difficult was it to reproduce your results?

It was not difficult.

What aspects made it difficult? What aspects made it easy?

I don’t think this counts as a difficulty since it’s just the nature of the data but the only hurdle was first confirming which variables represented condition and participant decision, since they had so many columns. Clear documentation in both the dataset and paper made it easy to verify. Learning more about tidyverse through this class + the stats bootcamp helped a lot.