## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>", 
  #fig.path = "",
  warning = FALSE, 
  message = FALSE
)

## ----setup--------------------------------------------------------------------
library(implicitMeasures)

## -----------------------------------------------------------------------------
data("raw_data")
# explore the dataframe
str(raw_data)
# explore the levels of the blockcode variable to identify the IAT blocks
levels(raw_data$blockcode)

## ----eval = T-----------------------------------------------------------------
iat_cleandata <- clean_iat(raw_data, sbj_id = "Participant",
                          block_id = "blockcode",
                          mapA_practice = "practice.iat.Milkbad",
                          mapA_test = "test.iat.Milkbad",
                          mapB_practice = "practice.iat.Milkgood",
                          mapB_test = "test.iat.Milkgood",
                          latency_id = "latency",
                          accuracy_id = "correct",
                          trial_id = "trialcode",
                          trial_eliminate = c("reminder", "reminder1"),
                          demo_id = "blockcode",
                          trial_demo = "demo")

## -----------------------------------------------------------------------------
str(iat_cleandata)

## -----------------------------------------------------------------------------
iat_data <- iat_cleandata[[1]]
head(iat_data)

## -----------------------------------------------------------------------------
dscore <- compute_iat(iat_data, Dscore = "d3")
str(dscore)

## -----------------------------------------------------------------------------
summary(dscore) 

## -----------------------------------------------------------------------------
IAT_rel(dscore)

## ----fig.align='center', fig.width=8, fig.height=6----------------------------
plot(dscore) # Data frame containing IAT D scores

## ----fig.align='center', fig.width=8, fig.height=6----------------------------
plot(dscore, graph = "points",
       order_sbj = "D-decreasing", # change respondents order
       x_values = FALSE, # remove respondents' labels
       include_stats = TRUE, # include descriptive statistics
       col_point = "lightskyblue") # change points color

## -----------------------------------------------------------------------------
multi_scores <- multi_dscore(iat_data, # object with class "iat_clean"
                             algorithms  = "error-inflation") # string specifying the 
                                            # algorithms to compute

## -----------------------------------------------------------------------------
plot(multi_scores)
plot(multi_scores, graph = "individual")

