R/curve_grades.R

Defines functions curve_grades

Documented in curve_grades

##' Curve grades according to a specified algorithm
##' @param x the object to be transformed
##' @param algorithm the curving algorithm to be
##' @param ... other arguments passed on to the transforming algorithm. Some of these are reloquired.
##' @return a transformed object
##' @export

curve_grades <- function(x, algorithm, ...) {

  # Set of algorithms the package knows about
  known.algorithms <- c("linear")

  # if statment to allow function to fail in a custom way if unknown algorithm is requested
  if(algorithm %in% known.algorithms) {

    # Choose algorithm based on input
    transformed <- switch(algorithm,
                    linear = linear_transform(x, ...))

  # Triggered if unknown algorithm is requested
  } else {
    stop(paste0("I'm not familiar with the algorithm "), algorithm,
         ". I only know about the following algorithms:", known.algorithms)
  }

  # return transformed data. Note this is agnostic as to what class of object is returned.
  transformed
}
adsteen/gradr documentation built on Dec. 18, 2017, 4:45 a.m.