#' Calculate raw score for speed and accuracy games
#'
#' This function calculates raw scores for tests that requires both accuracy
#' and speed. The score is calculated by get the number of correct per minute.
#'
#' @param data Raw data of class \code{data.frame}.
#' @param dur The time consumed in minute to complete the test.
#' @param ... Other input argument for future expansion.
#' @return The raw score calculated of \code{double} type.
#' @importFrom magrittr %>%
#' @export
meanscore <- function(data, dur = 3, ...) {
vars_correct <- c("ACC", "Repetition")
idx_var_correct <- utils::hasName(data, vars_correct)
if (!any(idx_var_correct)) {
warning("Variable that records correctness is required.")
return(NA_real_)
}
correctness <- dplyr::pull(data, vars_correct[idx_var_correct])
if (mean(correctness == -1) >= 0.2) {
warning("Response rate is too low.")
return(NA_real_)
}
sum(correctness == 1) / dur
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.