View source: R/data_standardization.R
| validate_lineup_data | R Documentation |
Checks whether a data frame meets the requirements for r4lineups confidence-based analyses. Ensures required columns exist with correct types and valid values.
validate_lineup_data(
data,
require_confidence = TRUE,
require_response_time = FALSE,
strict = FALSE
)
data |
A data frame to validate |
require_confidence |
Logical. Whether confidence column is required (default = TRUE). Set to FALSE for analyses that don't need confidence. |
require_response_time |
Logical. Whether response_time is required (default = FALSE) |
strict |
Logical. If TRUE, stops with error on validation failure. If FALSE, returns validation result with messages (default = FALSE) |
**Required columns:**
'target_present': Logical (TRUE/FALSE) indicating if target in lineup
'identification': Character or factor with values "suspect", "filler", or "reject"
'confidence': Numeric (if require_confidence = TRUE). Higher = more confident
**Optional columns:**
'participant_id': Unique identifier for each trial/participant
'response_time': Numeric response time in milliseconds
**Validation checks:**
All required columns present
Correct data types
No missing values in required columns
Valid identification values
Non-negative confidence values
At least some target-present and target-absent trials
If strict = FALSE, returns a list with:
valid: Logical indicating if data passes validation
messages: Character vector of validation messages/errors
warnings: Character vector of warnings (non-fatal issues)
If strict = TRUE, either returns TRUE invisibly or stops with error.
# Valid data
valid_data <- data.frame(
target_present = c(TRUE, TRUE, FALSE, FALSE),
identification = c("suspect", "filler", "reject", "suspect"),
confidence = c(5, 3, 2, 4)
)
validate_lineup_data(valid_data)
# Invalid data (missing column)
invalid_data <- data.frame(
target_present = c(TRUE, FALSE),
identification = c("suspect", "filler")
)
result <- validate_lineup_data(invalid_data, strict = FALSE)
print(result$messages)
# Strict validation (errors on failure)
validate_lineup_data(valid_data, strict = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.