#' Calculate raw score for stop watch test
#'
#' This function calculates raw score from json recording of "stopwatch" test.
#'
#' @param data Raw data of class \code{data.frame}.
#' @param ... Other input argument for future expansion.
#' @return The raw score calculated of \code{double} type.
#'
#' @importFrom magrittr %>%
#' @importFrom rlang .data
#' @export
stopwatch <- function(data, ...) {
if (!utils::hasName(data, "RT")) {
warning("Reaction time (`RT`) variable is required.")
return(NA_real_)
}
data_valid <- data %>%
dplyr::filter(.data$RT >= 100)
if (nrow(data_valid) / nrow(data) < 0.8) {
warning("Proportion of valid trials is too low.")
return(NA_real_)
}
data_valid %>%
dplyr::summarise(score = 1000 - mean(.data$RT)) %>%
dplyr::pull("score")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.