R/binary.R

Defines functions binary

Documented in binary

#' Compute the students' score of spheredata package
#'
#' Compute the students' score as binary/ dichotomous value. The calculation
#' method is based on a classical test theory prespective.
#' @param raw a dataframe of raw response data
#' @param key a dataframe of answer key
#'
#' @return a dataframe of dichotomous format of students' response data
#' @export binary
#' @examples
#' # Import the FCI score and key data
#' library(spheredata)
#' data("FCI")
#' data("FCIkey")
#'
#' # Processing the Force Concept Inventory (FCI) data as dichotomous
#' binary(FCI, FCIkey)

binary <- function(raw, key){
  dichotomous <- data.frame(t(apply(raw,1,function(X){ifelse(X==(key),1,0)})))
  colnames(dichotomous) <- names(raw)
  dichotomous
}

Try the spheredata package in your browser

Any scripts or data that you put into this service are public.

spheredata documentation built on April 4, 2025, 2:29 a.m.