#' Adding accuracy data to the data frame
#'
#' @param search.data
#'
#' @return
#' @export
#'
#' @examples
add_accuracy <- function(search.data) {
# Tabulate important quantities
combined_search_responses <- search.data %>%
dplyr::mutate(click.distance = round(sqrt((stimX - clickX)^2 + (stimY - clickY)^2), 3)) %>%
dplyr::mutate(click.dist.cent = round(sqrt((clickX)^2 + (clickY)^2), 3)) %>%
dplyr::mutate(dist.cent = round(sqrt(stimX^2 + stimY^2), 3)) %>%
dplyr::mutate(hit = ifelse(tPresent == "present" & response == "present" & click.distance <= threshold, 1, 0)) %>%
dplyr::mutate(miss = ifelse(tPresent == "present" & response == "absent", 1, 0)) %>%
dplyr::mutate(fa = ifelse(tPresent == "absent" & response == "present", 1, 0)) %>%
dplyr::mutate(cr = ifelse(tPresent == "absent" & response == "absent", 1, 0)) %>%
dplyr::mutate(fh = ifelse(tPresent == "present" & response == "present" & (click.distance > threshold), 1, 0)) %>%
dplyr::mutate(correct = ifelse(hit | cr, 1, 0)) %>%
tidyr::as_tibble()
return(combined_search_responses)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.