#' Calculate raw score for span type games
#'
#' This function calculates raw scores for multiple test games. These games
#' used a self adaptation method to collect users' behavior.
#'
#' @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
span <- function(data, ...) {
len_vars <- c("SLen", "NumTarget")
len_var <- len_vars[utils::hasName(data, len_vars)]
if (length(len_var) == 0) {
warning(paste("Stimulus length (`SLen`) or number of targets",
"(`NumTarget`) variable is required."))
return(NA_real_)
}
data %>%
dplyr::group_by(!!rlang::sym(len_var)) %>%
dplyr::summarise(PC = mean(.data$Outcome)) %>%
dplyr::summarise(
score = min(!!rlang::sym(len_var)) - 0.5 + sum(.data$PC)
) %>%
dplyr::pull("score")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.