Skip to contents

Counts the number of rows per participant and compares against expected trial counts. If expected_n is not supplied, the check reports the observed distribution without flagging anything. If expected_n is supplied, participants whose trial count is not in the allowed set are flagged.

Usage

check_trial_counts(
  responses,
  expected_n = NULL,
  method = c("2ifc", "briefrc"),
  col_participant = "participant_id",
  ...
)

Arguments

responses

Data frame with one row per trial. Required columns: participant_id, stimulus, response (values in {-1, +1}). Load yours from CSV via read_responses() or utils::read.csv(); column names are configurable via the col_* arguments.

expected_n

Optional. A single integer (all participants should have this many trials) or a vector of allowed counts (useful for designs with multiple trial-count conditions, e.g. c(300, 500, 1000)). If NULL, no flagging occurs.

method

Either "2ifc" or "briefrc". Currently informational.

col_participant

Name of the participant id column.

...

Unused. Reserved for consistency with other check functions.

Value

An rcisignal_diag_result() object. The data element contains per_participant, a data frame with one row per participant and their trial count.

Examples

responses <- data.frame(
  participant_id = rep(1:3, times = c(300, 300, 250)),
  stimulus       = 1,
  response       = 1
)
check_trial_counts(responses, expected_n = 300)
#> [FAIL] Trial counts
#>   1 of 3 participant{?s} have unexpected trial counts.
#>   Expected: {300}.
#>   Flagged counts: 3 (n=250).