d_density: Plot IAT or SC-IAT scores (distribution)

View source: R/d_density.R

d_densityR Documentation

Plot IAT or SC-IAT scores (distribution)

Description

Plot the distribution of the IAT D-score or the SC-IAT D.

Usage

d_density(
  data,
  graph = c("histogram", "density", "violin"),
  n_bin = 80,
  col_fill = "royalblue",
  col_point = "red",
  include_stats = FALSE
)

Arguments

data

Dataframe with either class dscore or dsciat.

graph

String. Indicates the graphs to display. Default is histogram

n_bin

Numeric. Indicates the number of bins to display.

col_fill

String. Indicates the color for filling the bars of the histogram or the curve of the density. Default is royalblue.

col_point

String. Indicates the color for the individual scores –each point – in the violin plot. Default is red.

include_stats

Logical. Indicates whether to add descriptive statistics. The mean is depicted with a solid line. The two dashed lines represent +/- 2 s.d. from the mean. Default is FALSE.

Value

A ggplot object.

Examples


  # Plotting the IAT D-score
  data("raw_data") # import data
  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")
  iat_data <- iat_cleandata[[1]]
# calculate D-score
  iat_dscore <- compute_iat(iat_data,
                       Dscore =  "d2")
  d_density(iat_dscore) # Default graph
  d_density(iat_dscore, graph = "histogram",
          n_bin = 30) # Histogram with a different number of bins
  d_density(iat_dscore, graph = "density") # IAT D-score density plot
  d_density(iat_dscore, graph = "violin") # IAT D-score violin plot

  # Plot the SC-IAT D for the first SC-IAT
  data("raw_data") # load data
  sciat_data <- clean_sciat(raw_data, sbj_id = "Participant",
                         block_id = "blockcode",
                         latency_id = "latency",
                         accuracy_id = "correct",
                         block_sciat_1 = c("test.sc_dark.Darkbad",
                                           "test.sc_dark.Darkgood"),
                         block_sciat_2 = c("test.sc_milk.Milkbad",
                                           "test.sc_milk.Milkgood"),
                         trial_id  = "trialcode",
                         trial_eliminate = c("reminder",
                                             "reminder1"))

 sciat1 <- sciat_data[[1]] # compute D for the first SC-IAT
 d_sciat1 <- compute_sciat(sciat1,
                  mappingA = "test.sc_dark.Darkbad",
                  mappingB = "test.sc_dark.Darkgood",
                  non_response = "alert")
  d_density(d_sciat1, graph = "histogram",
          include_stats = TRUE) # SC-IAT D histogram with descriptive
                                   #  statistics
                                   

implicitMeasures documentation built on March 18, 2022, 5:17 p.m.