R/accuracy.R

Defines functions accuracy

Documented in accuracy

#' Calculates raw score for games with accuracy of interest
#'
#' This function will output the percent of correct only.
#'
#' @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 %>%
#' @export
accuracy <- function(data, ...) {
  if (!utils::hasName(data, "ACC")) {
    warning("Accuracy (ACC) variable is required.")
    return(NA_real_)
  }
  if (mean(data$ACC == -1) >= 0.2) {
    warning("Response rate is too low.")
    return(NA_real_)
  }
  mean(data$ACC == 1)
}
psychelzh/dataprocr documentation built on Oct. 12, 2019, 1:50 a.m.