plot_import: Plot raw experiment data

View source: R/plot_import.R

plot_importR Documentation

Plot raw experiment data

Description

plot_import plots a single participant's data from import_single(), or a single participant (if !is.null(id)), or all participants' data from import_multiple().

Usage

plot_import(
  parsed_list,
  import_single = FALSE,
  id = NULL,
  types = c("train", "test", "affect"),
  plt.train = list(),
  plt.test = list(),
  plt.affect = list(),
  grp_compare = NULL,
  grp_names = c(),
  recode_na = NULL,
  aff_by_reward = FALSE,
  legend_pos = "right",
  pal = NULL,
  font = "",
  font_size = 14,
  ...
)

Arguments

parsed_list

import_single() or import_multiple() output.

import_single

Is the output from import_single()?

id

subjID to select if only plots for a single participant are desired. Will also accept a single numeric value i, which will select the ith participant in the output.

types

Types of plot to output, choose from any (or all) of train, test, and affect.

plt.train

List of length <= 2, with the first element a single value or numeric vector of the number of trials to lag in the calculation of cumulative probabilities, and the second element a vector of training types to include.

plt.test

List of length <= 2. The first element specifies the types of test pairs to plot; accepted inputs include "chooseA", "avoidB", "novel", "training", "all", and/or character vector(s) of specific pairs. The second input defines how these options are plotted - either "grouped" or "individual"; note "grouped" plots will not work for custom inputs or if "all" is selected as an option.

plt.affect

List of length <= 2 indicating (1) how many trials to lag (only a single value accepted), and (2) the nouns to plot (can be any of "happy", "confident", "engaged", or "fatigue"; defaults to all types).

grp_compare

Group to compare on which is found from the participant info. Note that if parsed_list is split into 2 (i.e., distanced and non-distanced), comparisons will be automatically made on this split.

grp_names

Vector of labels for plot keys for the different groups. An attempt will be made to label these automatically; it is recommended to first leave this list empty to make sure the correct labels are applied.

recode_na

Some grouping variables are NA in the participant information due to them being asked conditionally. This option enables these to be recoded as appropriate (e.g., to 0 or FALSE).

aff_by_reward

Enables affect plots to be compared by whether or not the prior stimulus was rewarded or not. This will override grp_compare (but won't affect other types of plots).

legend_pos

Enables the legend positions to be set manually.

pal

Define a custom colour palette for the plots? Otherwise reverts to defaults.

font

Use a custom font for the plots?

font_size

Base plot font size.

...

Other arguments, used internally by other functions calling this one.

Value

Either a single or named list of ggplot objects.

Examples

# Plot twenty-trial lagged training data, by distancing group
plot_import(
  example_data,
  types = "train",
  plt.train = list(20),
  grp_compare = "distanced"
)

# Plot test data for training and novel types, by sex
plot_import(
  example_data,
  types = "test",
  plt.test = list(c("training", "novel"), "individual"),
  grp_compare = "sex"
)

# Block end-of-block fatigue ratings in the non-distanced group only
plot_import(
  example_data$nd,
  types = "affect",
  plt.affect = list(20, "fatigue")
)


qdercon/pstpipeline documentation built on June 1, 2025, 1:11 p.m.